Created
May 22, 2019 02:12
-
-
Save shrekuu/399ec52962f56ed1fa0ff3c15a29c065 to your computer and use it in GitHub Desktop.
使用 nginx 代理帮助 "去掉" frp 代理用的端口号
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name example.com; # 指向你的网址 | |
resolver 223.5.5.5 208.67.222.222 8.8.8.8 valid=300s; | |
resolver_timeout 10s; | |
add_header X-Cache $upstream_cache_status; | |
location / { | |
proxy_pass http://127.0.0.1:8080; # frp 默认使用了 8080 端口 | |
proxy_redirect http://$host/ http://$http_host/; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_hide_header X-Powered-By; | |
proxy_hide_header Cache-Control; | |
proxy_hide_header Set-Cookie; | |
proxy_ignore_headers Cache-Control; | |
proxy_ignore_headers Set-Cookie; | |
# limit_conn perip 5; | |
limit_rate 128k; | |
} | |
location ~ .*\.(jpg|jpeg|gif|png|svg|css|scss|js|ico|xml|woff|woff2|ttf|otf|eot)$ { | |
resolver 127.0.0.1; | |
proxy_pass http://127.0.0.1:8080; # frp 默认使用了 8080 端口 | |
proxy_redirect http://$host/ http://$http_host/; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $host; | |
proxy_cache frp_cache; | |
proxy_cache_use_stale updating; | |
proxy_cache_key $uri$is_args$args; | |
proxy_cache_valid 200 206 301 302 304 3d; | |
proxy_cache_lock on; | |
proxy_cache_lock_timeout 5s; | |
# proxy_cache_use_stale updating error timeout invalid_header http_500 http_502; | |
proxy_http_version 1.1; | |
proxy_ignore_headers Cache-Control; | |
proxy_ignore_headers Set-Cookie; | |
proxy_hide_header Cache-Control; | |
proxy_hide_header Set-Cookie; | |
expires 3d; | |
# limit_conn perip 6; | |
limit_rate 128k; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment