添加nginx配置文件,解决nginx代理后无法获取客户端真实IP的问题

This commit is contained in:
2018-03-16 13:04:39 +08:00
parent 271934de3c
commit b55b735bb2
9 changed files with 118 additions and 8 deletions

44
cms.nginx - 副本.conf Normal file
View File

@@ -0,0 +1,44 @@
upstream cms-host{
server cms.fjy8018.xin:8085;
}
server {
listen 80;
listen 443 ssl;
server_name cms.fjy8018.xin; #域名
index index.html; #指定的server的root的访问页面
root /index; #指定的server的root目录
#SSL-START SSL相关配置请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#HTTP_TO_HTTPS_START
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
#HTTP_TO_HTTPS_END
ssl_certificate /www/wwwroot/cms/full_chain.pem;
ssl_certificate_key /www/wwwroot/cms/private.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
#SSL-END
#charset koi8-r;
#access_log logs/host.access.log main;
#我工程的context-path=mytest
location /cms {
proxy_pass http://cms.fjy8018.xin:8085;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
# root html;
# index index.html index.htm;
}
}