10

#Nginx 使用proxy_pass做反向代理的几条建议

 3 years ago
source link: https://xmanyou.com/nginx-proxy-guide/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
15 September 2021 / Nginx

#Nginx 使用proxy_pass做反向代理的几条建议

  • 1). proxy_pass中,目标服务器不带path
proxy_pass http://<目标服务器>:<端口>
  • 2). 使用rewrite来重写新路径
   rewrite ^ $request_uri;
   # 自动补充index.html
   rewrite ^/$ /index.html;
   # 补齐真正的路径
   rewrite ^/(.*)$ /newpath/$1 break;
  • 3). 即使路径一致也要用rewrite重写,避免二次转义
  • 4). 使用proxy_intercept_errors捕获错误,避免目标服务器暴露

阿斌

Read more posts by this author.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK