多选站点反向代理规则与伪静态

menglicl   ·   发表于 2023-8-1   ·   干货


# 伪静态
if ($uri !~* \.(?:ico|css|js|gif|jpe?g|png|txt|map|woff|woff2|ttf|svg|ttf)$) {
        rewrite ^/(.*)$ /$host/$1 last;
}
# HTTP反向代理相关配置开始 >>>
    location / {
        proxy_pass http://127.0.0.1:9008;
        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;
        proxy_set_header X-Host $host:$server_port;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 30s;
        proxy_read_timeout 86400s;
        proxy_send_timeout 30s;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    # HTTP反向代理相关配置结束 <<<


第二种反向代理


#PROXY-START/

location ^~ /
{
    proxy_pass http://127.0.0.1:9008;
    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_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_http_version 1.1;
    # proxy_hide_header Upgrade;

    add_header X-Cache $upstream_cache_status;

    #Set Nginx Cache
    
    
    set $static_fileHBAFYugh 0;
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
    	set $static_fileHBAFYugh 1;
    	expires 1m;
        }
    if ( $static_fileHBAFYugh = 0 )
    {
    add_header Cache-Control no-cache;
    }
}

#PROXY-END/


打赏我,让我更有动力~

0 条回复   |  直到 2023-8-1 | 269 次浏览
登录后才可发表内容
每日签到
0人
连续签到0天