Nginx代理节点服务器,提供常规的http请求和websockets。
对/download/<some directory>
的GET请求正在落到最后/
位置块。
NGINX配置如下所示:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location ^~ /.well-known {
alias /var/www/example/.well-known/;
allow all;
}
root /var/www/example/;
location /api {
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For-Proto https;
proxy_pass http://localhost:3000;
}
location /upload {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://localhost:3000/upload;
}
location /download {
proxy_set_header Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For-Proto https;
proxy_pass http://localhost:3000;
}
location / {
try_files $uri $uri/ /index.html;
}
}
如何使用以下格式正确匹配请求?
/download/<some directory>