Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

665
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!