1

I configured 3 server blocks on nginx for 3 different domain names. But I’m yet to buy domain names. If I enter server IP address like http://53.208.12.57/index.html it was only opening first website (/var/www/site1/index.html). How to see my 2nd & 3rd websites on (/var/www/site2/index.html and /var/www/site3/index.html)?

I also tried opening http://53.208.12.57/site2/index.html also, but it was not working. So what is the correct path to open 2nd website?

3
  • You can add them to your host files and use dummy domain names. Or you can point nginx to /var/www/ so you can use http://1.1.1.1/site2/index.html or http://1.1.1.1/site3/index.html.
    – majidarif
    Apr 22, 2017 at 5:32
  • 1
    The former may work better in some situations. OP needs to add an OS so you can post a more complete answer. What os is this on? ;p
    – Journeyman Geek
    Apr 22, 2017 at 5:35
  • Don't invent fake IPs in any case. You never need to hide private RFC1918 IPs (like 192.168.x.x), leave them as is; you want to replace your public IPs, you have to either replace them with private ones or with IPs from TEST-NET-x defined in RFC5735 (for example, 192.0.2.x). The use of "53.208.12.57" in the question is valid only if you really have that IP, and use of "1.1.1.1" in the comment above is absolutely invalid, don't do that. Jul 10, 2023 at 5:51

1 Answer 1

1

Currently, the IP address does not match any server_name in your configuration, so nginx will use the default server.

You can manually add the IP address to one of your sites for the purposes of testing that site, or add the keyword default_server to its listen directive to move the default server away from the first server block.

For example:

server_name site2.example.com 53.208.12.57;

Or:

listen 80 default_server;

I realise that this is not ideal, as you will need to restart nginx to test each website. You can specify the Host header with curl, but I do not think that is the kind of test you are interested in performing.

See this document for details.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .