Winginx NginX

ShadowIT
ShadowIT used Ask the Experts™
on
Hello Experts,

I am currently using Winginx for some internal development and I want to listen to a specific ip address other than localhost (127.0.0.1) to the actual ip address of the server so that it can be accessed across our intranet for testing purposes.

I've tried to configure the nginx.conf to listen to the server's ip address but that didn't work.  

Any help would be greatly appreciated.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Expert of the Year 2014
Top Expert 2014

Commented:
Why do you have at the moment?
What is happening?
Is the firewall blocking it?

Author

Commented:
Why do you have at the moment?  I don't understand this question.
What is happening? When I enter the server's ip address it doesn't work
Is the firewall blocking it? I made just the firewall allows nginx web server.
Expert of the Year 2014
Top Expert 2014

Commented:
Can you attach your nginx.conf
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Sure, I changed the file extension to .txt so I could upload it.
nginx.txt
Expert of the Year 2014
Top Expert 2014

Commented:
I don't see any config other than for 127.0.0.1
All you need to is copy the server block and change the IP
Once you've done that, restart Nginx and let me know if you get any error messages.

Author

Commented:
This is my point, I tried that and it didn't work so I changed it back to 127.0.0.1 to allow localhost to work again.
Expert of the Year 2014
Top Expert 2014

Commented:
Well that is all you need to do.
Are you sure you are editing the correct file.
As long as you are not getting any errors restarting nginx then the problem lies elsewhere.
Can you ping the servers IP from another pc?

Author

Commented:
Are you sure you are editing the correct file. (Gary) Not really, I am not that familiar using NginX.  I've used Apache and IIS but I am having a try at NginX but this seems to be the correct conf file.

As long as you are not getting any errors restarting nginx then the problem lies elsewhere. (Gary) After I add the server's ip address I restart all the services and don't get an error.  It seems fine and I don't see anything obvious.  I thought maybe there was something else that needed to be maintained for NginX

Can you ping the servers IP from another pc? (Gary) Yes so long at the client pinging it either on the network or behind the firewall via VPN.  Which is what I want and would expect.
Expert of the Year 2014
Top Expert 2014

Commented:
And what do you get when accessing the IP through the browser from another pc?

Remove the IP from the server block just leaving the port.
listen       80;

Let me just double check if there are any specific settings for Winginx, I use nginx and as far as I know the config is the same.

Author

Commented:
Internet Explorer cannot display the webpage

Author

Commented:
Wait, I misspoke....when I try and access it I get

"404 Not Found

--------------------------------------------------------------------------------

nginx/1.4.5"

So it seems to be trying to connect.
Expert of the Year 2014
Top Expert 2014

Commented:
It's connecting but no default page found which you have set as
index index.php index.html;

Author

Commented:
Well is that a normal config?  Is it supposed to be index index.php index.html;?  What I mean is when I have this set to 127.0.0.1 for localhost it seems to work fine then when I change this to my server's ip address I get the error 404.
Expert of the Year 2014
Top Expert 2014

Commented:
Can you post your server block
Did you remove the IP leaving just the Port? If so can you still access the site locally.

Author

Commented:
server {
 
    listen 164.145.158.122:80;
    server_name 164.145.158.122;
 
    # other instructions
 
}

Yes, I did remove the ip address just leaving the port and I was able to access the site locally.
Expert of the Year 2014
Top Expert 2014

Commented:
Change your listen/server name to this

   listen 80 default_server;
    server_name _;


I cannot think of a reason why you would be getting a 404 if it works locally.

Author

Commented:
ok, I changed it to:

server {
 
    listen 80 default_server;
    server_name _;
 
}

And when I tried to access the site locally it works, but when I tried from a client I get the same error 404.

404 Not Found

nginx/1.4.5
Expert of the Year 2014
Top Expert 2014

Commented:
Can you do an hard refresh in the browser, just to make sure its not cached.

Author

Commented:
I did that and I also tried to open it using Firefox which I haven't used previously, same error:

404 Not Found

nginx/1.4.5
Expert of the Year 2014
Top Expert 2014

Commented:
Can you load the site appending index.php (or whatever is your default index)

Author

Commented:
no, I tried the index.php and also index.html they both get the 404 error
Expert of the Year 2014
Top Expert 2014

Commented:
Can you attach your whole nginx.conf again.

Author

Commented:
I should mention that when I tried localhost locally I get:

It works!

Welcome to Winginx!

but it I try localhost/index.php or localhost/index.html I get the error 404.  it would seem that

It works!

Welcome to Winginx!

is the index message.

Author

Commented:
Sure, here you go...
nginx.txt
Expert of the Year 2014
Top Expert 2014

Commented:
You have localhost set
listen   127.0.0.1:80;

Author

Commented:
Yes, I know...if I leave it as the server's ip address it doesn't work locally so I have to change it back to 127.0.0.1:80;
Expert of the Year 2014
Top Expert 2014

Commented:
Just remove the ip so you have

listen  80;

It should still work locally

Author

Commented:
I've done as you've requested and it still does open locally.
Expert of the Year 2014
Top Expert 2014

Commented:
Can you verify that this is your document root
home/localhost/public_html
In that folder add your own index file, something simple like Hello world and verify it is opening in the browser.

Author

Commented:
Did "hello world" and it works fine locally when I open localhost in IE9 browser.
Expert of the Year 2014
Top Expert 2014

Commented:
And still a 404 from elsewhere on the network?

Author

Commented:
yes, damn this is frustrating...
Expert of the Year 2014
Top Expert 2014

Commented:
Thinking...

Author

Commented:
me too...but I just keep coming up with the same answers, this should work.
Expert of the Year 2014
Top Expert 2014

Commented:
Can you check permissions on the folder/files and set them to everyone.
All I can think of is that this is some kind of permission problem, tho it doesn't make sense.

Author

Commented:
Well I added Everyone to the top level folder within C:\Winginx just to ensure it was completely open and I am still getting error 404 if I try to access the web server using a client.  For that matter if I try to use the server's ip address locally I also get the error 404 and it seems to only work when I use localhost.  I rechecked the firewall and it does include the Winginx app for both TCP and UDP so I am at a complete loss as to why this isn't working.

What I was looking for when I first selected Winginx was an all-in-one application that contained MySQL, PHP and NginX so perhaps you could recommend something and I will just install that and forget about Winginx.  I'm just looking for something so I can easily config all of these apps together.
Expert of the Year 2014
Top Expert 2014

Commented:
WAMP or XAMPP (prefer XAMPP)
I will have a further ponder.
Puspharaj SelvarajSr.System engineer

Commented:
Can you run a trace route command from the internal network to see what happens ?

traceroute ip_address_of_the_server

Author

Commented:
My apologizes for the delayed response, when I ran tracert is resolved with the following:

Tracing route to TX92DT8LDNBZ1.global.ds.honeywell.com [164.145.158.122]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  TX92DT8LDNBZ1.global.ds.honeywell.com [164.145.1
58.122]

Trace complete.
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
Not sure if it helps but a 404 is served by the server so your network clients are connecting.
I suspect it's similar to connecting to MySQL remotely as you have to give specific permissions for the public server IP address to access from anywhere other than localhost.
Owner (Aidellio)
Most Valuable Expert 2015
Commented:
if (!-e $document_root$document_uri){return 404;}

Open in new window


comment out that line as it's most likely causing your issue

Author

Commented:
OK, now why exactly did this work?  But really I am just glad that it did, thank you.
RobOwner (Aidellio)
Most Valuable Expert 2015

Commented:
It works because commenting it out ignores the url rewrite or some form of it that is unique to NginX.
It could be a mechanism for blocking anything other than from localhost I'm not sure. Best thing would be to find those variables in the documentation somewhere and how they're used in the config file etc

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial