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;
}
- 反向代理 WebSocket
- Socket.io 文档
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;
}
预览: