5

[Linux笔记] Nginx 反向代理Discuz 规则[CDN]

这则反向代理是专门为一个朋友的论坛写的。论坛是DiscuzX1.5的程序。
由于Discuz都是动态页面,所以直接连html也排除缓存。
这一段是排除哪些后缀的网页,在括号里按格式填写后缀就可以了。

                location ~ .*\.(php|jsp|cgi|html)?$  {
                proxy_set_header  Host $host;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://www.xxx.com;
                }

完整的规则如下:

server{
                listen       80;
                server_name  www.xxx.com;
                index index.html index.htm index.php;
                root  /home/wwwroot/xxx.com;

location / {
                root    /home/wwwroot/xxx.com;
                proxy_redirect off ;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header REMOTE-HOST $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                client_max_body_size 50m;
                client_body_buffer_size 256k;
                proxy_connect_timeout 30;
                proxy_send_timeout 30;
                proxy_read_timeout 60;
                proxy_buffer_size 256k;
                proxy_buffers 4 256k;
                proxy_busy_buffers_size 256k;
                proxy_temp_file_write_size 256k;
                proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
                proxy_max_temp_file_size 128m;
                proxy_pass    http://www.xxx.com;
}

                location ~ .*\.(php|jsp|cgi|html)?$  {
                proxy_set_header  Host $host;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_pass http://www.xxx.com;
                }

    access_log  off;
}

5 Comments

梅达华进行回复 取消回复

电子邮件地址不会被公开。 必填项已用*标注