宝塔的Nginx反代缓存配置如何设置

我只反代图片和JS,配置文件该怎么写呢,是写在Nginx配置里面还是反代的配置文件里面

动态请求不处理

location ~* \.(php|jsp|cgi|asp|aspx)$
{
    proxy_pass https://104.19.19.19;
    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 REMOTE-HOST $remote_addr;
    proxy_ssl_name $host;
    proxy_ssl_server_name on;
}

全局不缓存

location /
{
    proxy_pass https://104.19.19.19;
    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 REMOTE-HOST $remote_addr;
    proxy_ssl_name $host;
    proxy_ssl_server_name on;
   
    add_header X-Cache $upstream_cache_status;
        #Set Nginx Cache
        proxy_ignore_headers Set-Cookie Cache-Control expires;
        add_header Cache-Control no-cache;
    expires 12h;
}

静态资源缓存2天

location ~* \.(htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|ico|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma|css|js)$
{
    proxy_pass https://104.19.19.19;
    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 REMOTE-HOST $remote_addr;
    proxy_ssl_name $host;
    proxy_ssl_server_name on;
   
    add_header X-Cache $upstream_cache_status;
        #Set Nginx Cache

    proxy_ignore_headers Set-Cookie Cache-Control expires;
    proxy_cache cache_one;
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_valid 200 304 301 302 2d;
    expires 12h;
}

网友说宝塔这个操作这个不行。

#PROXY-START/
location  ~* \.(php|jsp|cgi|asp|aspx)$
{
    proxy_pass http://127.0.0.1:8888;
    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 REMOTE-HOST $remote_addr;
}
location /
{
    proxy_pass http://127.0.0.1:8888;
    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 REMOTE-HOST $remote_addr;
   
    add_header X-Cache $upstream_cache_status;
   
    #Set Nginx Cache
   
            add_header Cache-Control no-cache;
    expires 12h;
}

#PROXY-END/
收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

栗子博客 软件 宝塔的Nginx反代缓存配置如何设置 https://www.lizi.tw/soft/19470.html

建筑工地上施工员,闲暇时弄个博客打发时间,

常见问题
  • 1、杰齐1.7仅适用于PHP5.2 2、需Zend支持 3、尽量使用宝塔面板 4、尽量使用Windows 系统,关关对Linux支持不太友好。
查看详情

相关文章

评论
暂无评论
宝塔的Nginx反代缓存配置如何设置-海报

分享本文封面