Nginx-反向代理防止url中需要端口号

Nginx-反向代理防止url中需要端口号,nginx,reverse-proxy,Nginx,Reverse Proxy,我有一个运行在https://localhost:3000 我有一个类似https://example.com/some/path 当我输入https://example.com/some/path进入我的浏览器,我希望它重定向到https://localhost:3000。因此,我认为这是可能的,就是使用反向代理,我正在尝试使用nginx设置来实现这一点 然而,我一直面临一个问题,当我转到完整url时,我需要包括端口号,例如:https://example.com:3000/some/path

我有一个运行在
https://localhost:3000

我有一个类似
https://example.com/some/path

当我输入
https://example.com/some/path
进入我的浏览器,我希望它重定向到
https://localhost:3000
。因此,我认为这是可能的,就是使用反向代理,我正在尝试使用nginx设置来实现这一点

然而,我一直面临一个问题,当我转到完整url时,我需要包括端口号,例如:
https://example.com:3000/some/path

如何防止这种情况发生?i、 e.我只想输入
https://example.com/some/path

我的nginx conf文件如下所示:

#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       443 ssl;
        server_name  example.com;

        ssl_certificate      cert.pem;
        ssl_certificate_key  cert.key;

        location /some/path {
        return 301 $scheme://localhost:3000$request_uri;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }


    server {
        listen 3000 ssl;

        ssl_certificate      cert.pem;
        ssl_certificate_key  cert.key;

        server_name localhost;
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";

        location / {
        proxy_pass https://localhost:3000;
    }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }

    include servers/*;
}
在我的主机文件中,我有一行:

127.0.0.1    example.com
即使我保持简单,并且只有一个服务器部分,其位置如下:

location /some/path {
   proxy_pass https://localhost:3000;
}
这种方法很有效——但是,查看控制台时,资产本身不会加载
https://example.com/static/js/bundle.js
当需要时
https://example.com:3000/static/js/bundle.js

任何帮助都将不胜感激