示例1,里面模拟的是用户访问一台Nginx服务器,Nginx代理后面一台真实服务器。
如果只是一台机器上设置也是类似的。
此外里面的域名和端口和证书,日志名称之类的根据自己的情况来定。
这个文件保存成一个name.conf在Nginx.conf中include即可。
upstream yourserver {
ip_hash;
server 172.16.10.10 weight=1 max_fails=2 fail_timeout=2;
}
server {
listen 80;
listen 443;
server_name yoursever.domain.com;
ssl on;
ssl_certificate /etc/ssl/certs/yourname.crt;
ssl_certificate_key /etc/ssl/certs/yourname.key;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://yourserver;
client_max_body_size 15m;
proxy_redirect off;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
}
access_log /var/log/nginx/yourserver.log main;
}
本回答被网友采纳