Problem with virtual host settings

So I have a info.php page which is located on the folder
/var/www/nginx-default, however when I go to my ip address/info.php, it
always redirects me to this site:
this because I have a virtual host that I called example? Here is my
config for the example website:
server {
listen 80;
rewrite ^/(.*)$1 permanent;

server {
listen 80;

 access_log /var/www/;
 error_log /var/www/;

 location / {
      root   /var/www/;
      index  index.html;


As I don’t have a domain name yet and I can only access the server via
terminal. The way I access this site via browser is by changing my
/etc/hosts in my macbook so that is mapped to my server IP
address. however now when I do in my macbook
browser it redirects me to that site I posted above, when I access from my macbook it works just fine.


Short answers:

  • Add to your /etc/hosts
  • In your second server block, change “listen 80” to “listen 80

Both should work.

Now, to understand why : have a look there