nginx 配置 tomcat 多服務請求攔截
阿新 • • 發佈:2021-08-25
#tomcat配置 worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #前端頁面伺服器 server { #監聽埠和域名 listen 80; #nginx 埠 server_name localhost; #新增攔截路徑和根目錄 #root"C:/Users/Admin/Desktop/A/src/main/webapp/"; #新增攔截路徑和代理地址 location / { #根目錄 root /root; proxy_pass http://localhost:8080/; #tomcat埠以及地址 } #新增攔截路徑和代理地址 後端程式碼埠以及 context-path: /api location /api/ { #請求攔截到的URL proxy_pass http://localhost:8090/api/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; index index.html index.htm; } } }