Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

335
Visualizações
Nginx - reverse proxy prevent needing port number in url

I have a React app that runs on https://localhost:3000.

I have a domain like https://example.com/some/path.

When I enter https://example.com/some/path into my browser, I'd like it to redirect to https://localhost:3000. So the way I've seen this possible is using a reverse proxy and I'm trying to nginx setup to do so.

However I keep facing in an issue that I need include the port number when I go to the full url for example: https://example.com:3000/some/path.

How do i prevent this from happening? i.e. I'd like to just enter https://example.com/some/path.

My nginx conf file looks like this:

#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/*;
}

And in my hosts file I have the line:

127.0.0.1    example.com

Even if I keep it simple and have only one server section with location like:

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

That kind of works - however looking at the console the assets themselves don't load https://example.com/static/js/bundle.js when it needs to be https://example.com:3000/static/js/bundle.js

Any help would be appreciated.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda