nginx - 带有反向代理的 NESTJS 502 或 404
问题描述
问题:nextJS api 应用程序的 502 或 404
nestJS 适用于 url https://www.domain-name.com:3000/api/test中的端口
但是 proxy_pass http://localhost:3000; 返回 502 或 404 取决于 url
此设置适用于相同的 expressJS 应用程序。不接受 POST 或通过反向代理获取调用的 nestJS 有什么不同
这里是 nginx
server {
server_name www.domain_name.com;
location / {
try_files $uri $uri/ =404;
root /var/www/domain_name/html;
index index.php index.html index.htm;
}
location /rest/v2 {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass %http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000;
proxy_set_header Accept-Encoding gzip;
proxy_set_header X-Forwarded-Proto $scheme;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
letsencrypt setup>>>>
rest of config>>>>
}
如果我忽略了与 nestJS 服务器的连接,任何输入都将不胜感激
谢谢你。
解决方案
推荐阅读
- java - Android setOnClickListener 一键触发两次
- php - PHP json_encode - 合并
- django - Django Admin:限制内联表单的查询集选择
- java - 在 JavaFX 中更改场景后如何存储数据库中的字段?登录后需要从数据库表中捕获一个“ID”
- javascript - 如何让 ScrollView 从底部开始,并在 Google Map 组件上滚动?
- linux - 每次运行时将任意目录设置为 root 的 chroot 进程监狱
- php - 使用 SSL 和 Let'sEncrypt 证书,使用共享 Dreamhost Apache 服务器,用于带有 Ratchet 的 React SecureServer
- python - plt.annotate() 在 matplotlib 的新行中
- flutter - 在颤振中运行网络服务器
- javascript - Firebase Phone Auth Recaptcha Verifier 未设置为窗口/加载