ngxin設定:
proxy_set_header Host $http_host;
程式碼片段如下:
server {
listen 80;
server_name www.aso.ren;
autoindex off;
location / {
root /da/www/webapps;
index index.html index.jsp;
proxy_pass http://localhost:8080;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
備註:
proxy_set_header Host $http_host; # 將當前Host頭域值填充成客戶端地址
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 代理路由資訊,此處取ip有安全隱患
proxy_set_header X-Forwarded-Proto $scheme; # 真實使用者訪問協議
proxy_set_header X-Real-IP $remote_addr; # 真實使用者IP