如何解决NGINX 502坏网路错误

发布于 2025-01-24 09:04:35 字数 459 浏览 0 评论 0原文

我已经将extal.js Web应用程序进行了容器,并在AWS EC-2中托管。使用nginx作为代理服务器,

这是唯一的工作页面

/

不适用于任何其他页面(路径),它会抛出 502 Bad Gate-way

ex:

/etc

/slug/page

这是nginx cofiguration

server {
listen 80 default_server;


location  / {
  proxy_pass http://localhost:300;
}

}

如何将所有路径转发到特定端口?

I've containerized the next.js web application and hosted in aws ec-2. using nginx as proxy server

this is the only working page

/

not working for any other pages (paths),it throws 502 bad-gate-way

EX:

/etc

/slug/page

this is the nginx cofiguration

server {
listen 80 default_server;


location  / {
  proxy_pass http://localhost:300;
}

}

how can I Forward all paths to a specific port?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流殇 2025-01-31 09:04:35
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 / {
                # reverse proxy for next server
                proxy_pass http://localhost:300;
                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;

            # we need to remove this 404 handling
                # because next's _next folder and own handling
                # try_files $uri $uri/ =404;
        } 

        location ~ /.well-known {
                allow all
        }
} 

我添加了此Nginx配置,现在正常工作。

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 / {
                # reverse proxy for next server
                proxy_pass http://localhost:300;
                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;

            # we need to remove this 404 handling
                # because next's _next folder and own handling
                # try_files $uri $uri/ =404;
        } 

        location ~ /.well-known {
                allow all
        }
} 

I've add this nginx configuration, now it's working fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文