Link to home
Start Free TrialLog in
Avatar of ShadowIT
ShadowITFlag for United States of America

asked on

Winginx NginX

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
Avatar of Gary
Gary
Flag of Ireland image

Why do you have at the moment?
What is happening?
Is the firewall blocking it?
Avatar of ShadowIT

ASKER

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.
Can you attach your nginx.conf
Sure, I changed the file extension to .txt so I could upload it.
nginx.txt
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.
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.
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?
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.
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.
Internet Explorer cannot display the webpage
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.
It's connecting but no default page found which you have set as
index index.php index.html;
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.
Can you post your server block
Did you remove the IP leaving just the Port? If so can you still access the site locally.
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.
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.
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
Can you do an hard refresh in the browser, just to make sure its not cached.
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
Can you load the site appending index.php (or whatever is your default index)
no, I tried the index.php and also index.html they both get the 404 error
Can you attach your whole nginx.conf again.
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.
Sure, here you go...
nginx.txt
You have localhost set
listen   127.0.0.1:80;
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;
Just remove the ip so you have

listen  80;

It should still work locally
I've done as you've requested and it still does open locally.
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.
Did "hello world" and it works fine locally when I open localhost in IE9 browser.
And still a 404 from elsewhere on the network?
yes, damn this is frustrating...
Thinking...
me too...but I just keep coming up with the same answers, this should work.
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.
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.
WAMP or XAMPP (prefer XAMPP)
I will have a further ponder.
Can you run a trace route command from the internal network to see what happens ?

traceroute ip_address_of_the_server
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.
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.
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, now why exactly did this work?  But really I am just glad that it did, thank you.
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