0

I'm working on a mac, using VirtualBox and Ubuntu server 20.04 using a Bridged Connection. I have set up the Nginx server and the default page is loading. I was able to edit /var/www/html/index.html to say hello world. I can view this default page by visiting http://ip/.

The server blocks files in /var/www/ are named 'html' (the default), 'site1' and 'site2' All the 'site' maps have a html map inside of them, containing index.html with some HelloWorld text inside of them.

All the above code/info should be correct. Therefore, I assume that the error is in the configuration.

/etc/nginx/sites-enabled contain 3 files. 'default', 'site1' and 'site2'. I will show the 'default' file and the 'site1' file in the code below.

Going to http://site1/ results in an error page, chrome displays an IP error instead of the index.html file.

Could someone show me what I'm doing wrong?

Site1 file:

server {
    listen 80;
    listen [::]:80;

    root /var/www/site1/html;
    index index.html index htm index.nginx-debian.html;

    server_name site1 www.site1;

    location / {
            try_files $uri $uri/ =404;
    }
}

Default file:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
            try_files $uri $uri/ =404;
    }

}

1
  • 192.168.178.52 is your private ip. No one can use that. Commented Jul 2, 2020 at 14:30

1 Answer 1

1

Your server_name site1 www.site1; is wrong because there are not any local domain names like site1 or www.site1 that configured in your computer to route to 127.0.0.1.

So you need to config a local domain on your computer so whenever you browse site1 or www.site1 they will be routed to 127.0.0.1. On ubuntu, just change the /etc/hosts file to sth like this:

127.0.0.1   localhost
127.0.0.1   site1
127.0.1.1   www.site1

However im not sure how to make samething done on MacOS because i have never use mac lol. But I found a link that might help you :

https://markinns.com/archive/how-to-setup-a-local-dns-host-file-on-mac-os-x.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.