| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 
 | upstream backend{
 server 127.0.0.1:8443;                        #设置代理地址
 #keepalive 16;                                     #启动后端长连接
 }
 
 server {
 listen    80;
 server_name domain1 domain2;
 return 301 https://$host$request_uri;
 }
 
 server {
 listen 443 ssl;                                  #监听端口
 server_name domain1 domain2;                     #监听地址,域名可以有多个,用空格隔开,一般填写域名、IP,可配置阻止其他server_name访问
 
 #配置ssl
 ssl_certificate ssl/*.crt;
 ssl_certificate_key ssl/*.key;
 
 root html;                                        #根目录
 index index.php index.htm index.html;             #默认页
 #动态请求代理给相应服务器
 location / {
 #include     agent_deny.conf;                 #屏蔽爬虫攻击,需要外部配置,默认关闭,配置好外部配置打开
 #limit_req zone=ConnLimitZone burst=1 nodelay; #设置限速1个排队
 #limit_conn  TotalConnLimitZone  100;          #限制每个IP只能发起100个并发连接
 proxy_set_header Host  $host:$server_port;    #修改Host头为用户真实Host,不修改这会统一发送代理服务器的Host,后端服务会认为都是代理服务器发送的请求。
 proxy_set_header X-Real-IP $remote_addr;      #使后端服务拿到用户真实IP
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #获取用户真实IP地址
 proxy_redirect off;                           #作用是对发送给客户端的URL进行修改!off设置为关闭此功能http://$host:8200/   http://$http_host/;
 proxy_http_version 1.1;                       #设置Http协议版本
 proxy_pass http://backend;                    #转向定义服务列表,如果只做代理可以直接设置为http://127.0.0.1:10000
 }
 
 #S3配置
 location ^~ /s3-configuration/ {
 alias /app/s3-configuration/;
 }
 
 
 #缓存相应的文件(静态文件)
 location ~ \.(gif|jpg|jpeg|png|htm|html|css|js|flv|ico|swf|mp3)(.*) {
 #include     agent_deny.conf;                 #屏蔽爬虫攻击,需要外部配置,默认关闭,配置好外部配置打开
 #limit_req zone=ConnLimitZone burst=1 nodelay; #设置限速1个排队
 #limit_conn  TotalConnLimitZone  100;          #限制每个IP只能发起100个并发连接
 proxy_set_header Host  $host:$server_port;    #修改Host头为用户真实Host,不修改这会统一发送代理服务器的Host,后端服务会认为都是代理服务器发送的请求。
 proxy_set_header X-Real-IP $remote_addr;      #使后端服务拿到用户真实IP
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#获取用户真实IP
 #proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;    #强制缓存,部分应用会不让静态页面缓存,此方法可以强制缓存静态页,默认关闭
 proxy_redirect off;                           #作用是对发送给客户端的URL进行修改!off设置为关闭此功能http://$host:8200/   http://$http_host/;
 proxy_http_version 1.1;                       #设置Http协议版本
 proxy_pass http://backend;                    #转向定义服务列表,如果只做代理可以直接设置为http://127.0.0.1:10000
 proxy_cache cache_one;                        #设置缓存共享内存区块,也就是keys_zone名称
 proxy_cache_valid 200 302 1h;                 #对不同的HTTP状态码设置不同的缓存时间,h小时,d天数
 proxy_cache_valid 301 1d;
 proxy_cache_valid any 1m;
 expires 7d;                                   #设置用户浏览器缓存文件失期时间,设置为-1时浏览器不进行缓存
 }
 }
 
 |