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

659
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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