Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

666
Vistas
nginx: Is there any way to avoid wriring server ip address in nginx config file?

I used nginx as a reverse proxy in a simple express app. In my config file, I have used server ip(http://45.33.97.232/) as server_name.

but is there any way to avoid writing the actual server ip in this file without breaking anything?

server {
    listen 80 default_server;
    server_name 45.33.97.232;

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://45.33.97.232:3000; #port where you are serving your express app.

  }
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Yes. By setting the default_server flag in the listen directive and setting the server name to any invalid domain name. Typically the name _ is used in nginx example config files but this can be any invalid domain name such as ! etc:

server {
    listen 80 default_server;
    server_name _;

    ...
}

See http://nginx.org/en/docs/http/server_names.html#miscellaneous_names for more info on this.


Note that there is one special server name that has an additional meaning. If you need to serve clients that don't send the Host header (eg. HTTP/1.0 clients) then the empty string is used to signal that this server block is the one that is meant to serve such clients. So the server_name can be set to two double quotes ("") to signify empty string:

server {
    listen 80;
    server_name "";

    ...
}

Note though that this does not function as a catch-all domain name like the _ above. Instead it catches requests with empty host header.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda