Welcome! Log In Create A New Profile

Advanced

Unable to display static content on same server

Posted by thg 
thg
Unable to display static content on same server
August 07, 2015 06:56AM
Hi,

I am newbie to Nginx and has been asked to do the following. My company has a new website underway and they would like to register the new site in our DNS (netscaler) and display an "under construction" message if someone visits the page. My network guys have registered the name in DNS and redirects www.example.com to my windows Nginx server. On Nginx I have added this to my config and restarted Nginx:

server {
listen 80;
server_name www.example.com;
location / {
root D:\wwwroot;
}
}

On the Nginx server I have added a folder wwwroot on my D drive and placed a file called index.html (just a simple Word document containing the under construction message and saved it as .html)

When I try to visit www.example.com in my browser it fails to load my index.html and all I see is a Http/1.1 Service Unavailable message

For testing purposes I have tried to add this to an already working domain of ours and then it works?! What I did to get this to work is the following.

In Nginx config:

server {
listen 80;
server_name www.workingdomain.com;
location /test {
root D:\wwwroot;
}
}

On Nginx D drive:

Inside "wwwroot" folder I placed a folder called "test" and put my index.html there. All works fine?!

Any suggestions as to why it does not work without a location set?

Cheers
thg
Re: Unable to display static content on same server
August 07, 2015 07:19AM
Look in the logfiles to see if your request actually reaches your webserver.

---
nginx for Windows http://nginx-win.ecsds.eu/
thg
Re: Unable to display static content on same server
August 07, 2015 09:46AM
Thanks itpp2012 for your reply.

I can't find any traces in either access or error log. Yesterdays test to www.workingdomain.com/test however is there (access log)
Just verified with the network guys that netscaler has been configured properly and pointing to my Nginx.

Any tip appreciated.

Cheers
thg
Re: Unable to display static content on same server
August 07, 2015 10:01AM
If there is nothing in the logs then that nginx instance is not being reached, do a trace over port 80 to this machine and see where you end up, also access the machine locally to ensure (by checking the logs) it is answering as configured.

---
nginx for Windows http://nginx-win.ecsds.eu/
thg
Re: Unable to display static content on same server
August 07, 2015 10:29AM
When pinging from internal server my netscaler replies successfully. Same as for other working websites handled by the Nginx. When trying to access webpage externally I get the Http/1.1 Service Unavailable message error. However when trying from an internal server I get a 403 forbidden from the Nginx server. Now looking, the error log gives me this:

Line 556: 2015/08/07 15:18:15 [error] 10352#13280: *10149129 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 556: 2015/08/07 15:18:15 [error] 10352#13280: *10149129 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 557: 2015/08/07 15:18:23 [error] 10352#13280: *10148766 CreateFile() "D:\wwwroot/favicon.ico" failed (2: The system cannot find the file specified), client: 194.143.62.38, server: www.example.com, request: "GET /favicon.ico HTTP/1.1", host: "www.example.com"
Line 557: 2015/08/07 15:18:23 [error] 10352#13280: *10148766 CreateFile() "D:\wwwroot/favicon.ico" failed (2: The system cannot find the file specified), client: 194.143.62.38, server: www.example.com, request: "GET /favicon.ico HTTP/1.1", host: "www.example.com"
Line 558: 2015/08/07 15:18:31 [error] 10352#13280: *10149129 CreateFile() "D:\wwwroot/favicon.ico" failed (2: The system cannot find the file specified), client: 194.143.62.38, server: www.example.com, request: "GET /favicon.ico HTTP/1.1", host: "www.example.com"
Line 558: 2015/08/07 15:18:31 [error] 10352#13280: *10149129 CreateFile() "D:\wwwroot/favicon.ico" failed (2: The system cannot find the file specified), client: 194.143.62.38, server: www.example.com, request: "GET /favicon.ico HTTP/1.1", host: "www.example.com"
Line 561: 2015/08/07 15:49:57 [error] 10352#13280: *10158125 CreateFile() "D:\wwwroot/robots.txt" failed (2: The system cannot find the file specified), client: 194.143.62.38, server: www.example.com, request: "GET /robots.txt HTTP/1.1", host: "www.example.com"
Line 561: 2015/08/07 15:49:57 [error] 10352#13280: *10158125 CreateFile() "D:\wwwroot/robots.txt" failed (2: The system cannot find the file specified), client: 194.143.62.38, server: www.example.com, request: "GET /robots.txt HTTP/1.1", host: "www.example.com"
Line 562: 2015/08/07 15:49:57 [error] 10352#13280: *10158125 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 562: 2015/08/07 15:49:57 [error] 10352#13280: *10158125 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 563: 2015/08/07 16:01:18 [error] 10352#13280: *10160519 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 563: 2015/08/07 16:01:18 [error] 10352#13280: *10160519 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 564: 2015/08/07 16:01:37 [error] 10352#13280: *10160527 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"
Line 564: 2015/08/07 16:01:37 [error] 10352#13280: *10160527 directory index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server: www.example.com, request: "GET / HTTP/1.1", host: "www.example.com"

Cheers
thg
Re: Unable to display static content on same server
August 07, 2015 10:59AM
thg Wrote:
-------------------------------------------------------
> When pinging from internal server my netscaler replies successfully.
> Same as for other working websites handled by the Nginx. When trying
> to access webpage externally I get the Http/1.1 Service Unavailable
> message error. However when trying from an internal server I get a 403
> forbidden from the Nginx server. Now looking, the error log gives me

So your are not reaching your server as you have 2 different responses.

> Line 556: 2015/08/07 15:18:15 [error] 10352#13280: *10149129 directory
> index of "D:\wwwroot/" is forbidden, client: 194.143.xx.xx, server:

Add:
index index.html index.htm;
to its location block.

---
nginx for Windows http://nginx-win.ecsds.eu/
thg
Re: Unable to display static content on same server
August 07, 2015 12:25PM
I added index index.html index.htm; to my location block and also placed a favicon.ico file in my wwwroot folder and voila, it works. However if I simply type example.com I get the http/1.1 error again as it adds https in front. Something for my network guys maybe or is it resolvable within Nginx?

Cheers
thg
Re: Unable to display static content on same server
August 07, 2015 01:17PM
(a)internet -> (b)firewall -> (c)netscaler -> (d)machine-with-nginx.

If accessing (d) works for both http and https then the config is ok.
If accessing (d) via (a) does not work you should obviously now see the problem can be at a,b and/or c.
Also check if (d) doesn't have a firewall actively blocking anything from outside (d).

---
nginx for Windows http://nginx-win.ecsds.eu/
thg
Re: Unable to display static content on same server
August 13, 2015 06:25AM
Hi,

Got to talk to my network guys and they said something about wildcards that was not added?! and that that was why only www.example.com would work. I consider this solved then. Thank you itpp2012 for your help!

Cheers
thg
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 133
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready