spring clould -多模块 -swagger2 配置 nginx 的正确设置
作者:互联网
#user nobody; worker_processes 2; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; #keepalive_timeout 0; #网关连接时间最长1600秒 keepalive_timeout 3600; # 后台集群地址 upstream eureka { server 127.0.0.1:51; # server 192.168.0.45:8000; } upstream zuul { server 127.0.0.1:52; } upstream permission { server 127.0.0.1:53; } upstream vue { server 127.0.0.1:59; } server { listen 50; server_name api.cenxi.cn; #gzip on; #--------------------------------- #上传包的大小 client_max_body_size 500m; # 从建立连接开始到发送完head的时间 client_header_timeout 10s; #发送完head以后到发送完body的时间 client_body_timeout 10s; #和后端建立连接的时间(3次握手) proxy_connect_timeout 60s; proxy_read_timeout 60s; proxy_send_timeout 60s; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #--------------------------------- location ^~ /wieixin { proxy_pass http://zuul/wieixin; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; #proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; } location ^~ /manage { proxy_pass http://zuul/manage; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; #proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; } location ^~ /permission { proxy_pass http://zuul/permission; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; #proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; } location ^~ /zuul { proxy_pass http://zuul; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; #proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; } location ^~ /eureka { proxy_pass http://eureka/; } # vue前端 ,访问 http://localhost:50/ location ^~ / { proxy_pass http://vue/; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }View Code
标签:set,Forwarded,nginx,spring,swagger2,server,header,Host,proxy 来源: https://www.cnblogs.com/c2g5201314/p/15695515.html