Skip to content
Spotify - 每月低于 10 元

Nginx 快速上手

反向代理

  • 访问 domain.com/zone/api/
  • 相当于访问 127.0.0.1:8000/api/
nginx
location /zone/api/ {
    proxy_pass http://127.0.0.1:8000/api/;
    proxy_set_header Host $host;
}
nginx
location /socket.io/ {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

指定文件路径

  • 访问 domain.com/zone/images/
  • 相当于访问 /www/wwwroot/zone/public/images/
  • 官方文档
nginx
location ~ ^/zone/images/(.+\.(?:gif|jpe?g|png))$ {
    alias /www/wwwroot/zone/public/images/$1;
}
关注微信公众号RackNerd - 美国 163 直连线路
你认为这篇文章怎么样?
  • 0
  • 0
  • 0
  • 0
  • 0
  • 0

预览:

评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3