server {
listen 80;
listen [::]:80;
server_name xxxxx.cn;
proxy_intercept_errors on;
index index.html index.htm;
# root /raray/wwwroot;
error_page 404 500 502 503 504 /50x.html;
location /50x.html {
root /usr/share/nginx/html;
}
location /healthz {
add_header Content-Type "text/plain";
return 200 "OK";
}
location /dspx_meta_api/ {
client_max_body_size 120m;
proxy_connect_timeout 150s;
proxy_send_timeout 5m;
proxy_read_timeout 5m;
proxy_temp_file_write_size 1024m;
proxy_buffer_size 1m;
proxy_buffers 4 4m;
proxy_busy_buffers_size 4m;
proxy_ignore_client_abort on;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Scheme $scheme;
proxy_pass http://dspx_engine_meta:8080/;
}
location / {
proxy_redirect off;
proxy_pass http://dmp-ops-web:80/;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Nginx-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
location /remote_addr {
default_type text/plain;
return 200 "$remote_addr\n";
}
}
配置成功的项目
server{
listen 80 ;
server_name xxxxxx.cn ;
location ^~ /kaoshi/ {
proxy_redirect off;
proxy_pass http://localhost:8088/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Nginx-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
}
标签:set,http,Forwarded,多个,header,host,nginx,域名,proxy
From: https://www.cnblogs.com/hefeng2014/p/16780207.html