多选站点反向代理规则与伪静态
时间:08-26
作者:
# 伪静态if ($uri !~* \.(?:ico|css|js|gif|jpe?g|png|txt|map|woff|woff2|ttf|svg|ttf)$) { rewrite ^/(.*)$ /$host/$1 last;}# HTTP反向代理相关配置开始 >>>
# 伪静态
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/