Tengo una aplicación React que se ejecuta en https://localhost:3000 .
Tengo un dominio como https://example.com/some/path .
Cuando ingreso https://example.com/some/path en mi navegador, me gustaría redirigir a https://localhost:3000 . Entonces, la forma en que he visto que esto es posible es usando un proxy inverso y estoy tratando de configurar nginx para hacerlo.
Sin embargo, sigo enfrentando un problema que necesito incluir el número de puerto cuando voy a la URL completa, por ejemplo: https://example.com:3000/some/path .
¿Cómo evito que esto suceda? es decir, me gustaría simplemente ingresar https://example.com/some/path .
Mi archivo nginx conf se ve así:
#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/*; }Y en mi archivo de hosts tengo la línea:
127.0.0.1 example.comIncluso si lo mantengo simple y solo tengo una sección de servidor con una ubicación como:
location /some/path { proxy_pass https://localhost:3000; } Eso funciona; sin embargo, al mirar la consola, los activos en sí no se cargan https://example.com/static/js/bundle.js cuando debe ser https://example.com:3000/static/js/bundle.js
Cualquier ayuda sería apreciada.