<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:10pt"><div>Hello,<br><br>Short answers:<br><span>- Add <a target="_blank" href="http://www.example.com">www.example.com</a> to your /etc/hosts</span><br>OR<br>- In your second server block, change "listen 80" to "listen 80 default;".<br><br>Both should work.<br><br><span>Now, to understand why : have a look there <a target="_blank" href="http://nginx.org/en/docs/http/request_processing.html">http://nginx.org/en/docs/http/request_processing.html</a></span><br><br>A.<br></div><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-family: times new roman,new york,times,serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font face="Tahoma" size="2"><b><span style="font-weight:
 bold;">From:</span></b> Aditya Herlambang &lt;aditya15417@hotmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> nginx@nginx.org<br><b><span style="font-weight: bold;">Sent:</span></b> Tue, March 1, 2011 6:08:53 AM<br><b><span style="font-weight: bold;">Subject:</span></b> problem with virtual host settings<br></font><br>


<style><!--
.hmmessage P
{
margin:0px;padding:0px;}
body.hmmessage
{
font-size:10pt;font-family:Tahoma;}
--></style>

<br><br><div></div><br><span class="Apple-style-span" style="border-collapse: collapse; font-family: Arial,sans-serif; font-size: 14px; line-height: 18px;"><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">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:</p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;"><span><a target="_blank" href="http://www.iana.org/domains/example/">http://www.iana.org/domains/example/</a></span></p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap:
 break-word;">is this because I have a virtual host that I called example? Here is my config for the example website:</p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;"><br></p><pre style="margin: 0px 0px 10px; padding: 5px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-family: Consolas,Menlo,Monaco,monospace,serif; width: auto; max-height: 600px;"><code style="margin: 0px; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(238, 238, 238); font-family: Consolas,Menlo,Monaco,monospace,serif;">server {<br>     listen   80;<br>     server_name  <a target="_blank" href="http://www.example.com">www.example.com</a>;<br><span>     rewrite ^/(.*) <a target="_blank" href="http://example.com/$1">http://example.com/$1</a>
 permanent;</span><br>     }<br><br>server {<br>     listen   80;<br>     server_name <a target="_blank" href="http://example.com">example.com</a>;<br><br>     access_log /var/www/example.com/logs/access.log;<br>     error_log /var/www/example.com/logs/error.log;<br><br>     location / {<br>          root   /var/www/example.com/public/;<br>          index  index.html;<br>          }<br>}<br></code></pre><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;"><br></p><p style="margin: 0px 0px 1em; padding: 0px; border-width: 0px; font-size: 14px; vertical-align: baseline; background-color: transparent; clear: both; word-wrap: break-word;">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 example.com is mapped to my
 server IP address. however now when I do xxx.xxx.xxx.xxx/info.php in my macbook browser it redirects me to that site I posted above, when I access example.com from my macbook it works just fine.</p></span>                                               </div></div></blockquote>
</div><br>

      </body></html>