首页 > 解决方案 > 带有反向代理的Nodejs

问题描述

我目前正在使用 NodeJs over Nginx 来托管网站,因为我已经意识到 Nginx 的端口冲突,我已经更改了配置文件,我现在可以访问 localhost。但问题是该网站不再与托管在端口 3000 上的网站相同(我将 NodeJs 源设置为监听)它真的很挣扎,我真的希望有人能给我一个解决方案。

配置代码如下

server {
        listen 80 default_server;
        listen [::]:80 default_server;
 root /var/www/html;
        index index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                proxy_pass http://localhost:3000;
                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;
        }

标签: nginxreverse-proxynginx-reverse-proxy

解决方案


推荐阅读