我有一个在expressjs应用程序与以下代码的路线。
...
router.get("/:id", async (req, res, next) => {
try {
// debug(`The req is ${req.params.id}`);
const data = await getSuperHerors(req.params.id);
res.send(data);
} catch (err) {
next(err);
}
});
...
我想设置我的nginx revere代理转发的id。配置文件的nginx是在这里...服务器{ root /var/www/html;
server_name example.biz; # managed by Certbot
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
# proxy_pass http://127.0.0.1:3000/$1$is_args$args;
# set $upstream http://localhost:3000;
# proxy_pass $upstream/$1$is_args$args;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.biz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.biz/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = example.biz) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name example.biz;
return 404; # managed by CertbotWhat is wrong with my reverse proxy file.
}
...我的反向代理文件有什么问题。现在我已经把它放回原来的状态,但是我已经尝试使用注解后面的配置。
约瑟夫·沙纳汉
1条答案
按热度按时间n3h0vuf21#
谢谢,你是对的,所有的请求都被转发了。我回去看了看我的设置,发现了一些其他的错误。干杯约瑟夫沙纳汉