Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Wed May 06, 2015 7:37 am 
Offline
Newbie

Joined: Wed May 06, 2015 7:10 am
Posts: 4
hello,

i am a developer with absolutely no server experience, this project im working on is my first foray into the world of servers. Basically i have to host an API online, on a Linode server running Nginx on Ubuntu. And im having trouble getting a simple server block set up to host a html index page, with just a h1 tag saying 'hello'. I've followed and read various tutorials on getting a simple server block working, i've even got these blocks working on my local machine, but im having issues getting it to work on the remote server.

il show you some blocks that have failed to work for me on the Linode:

first, a simple block to server a static html page, this works on my local machine:

server {

listen 8005;
index index.html;
root /srv/www/site;

}


another simple block:

server {

listen [server ip]:8006;
server_name "";
index index.html;
root /srv/www/site;

location ~/ {

root /srv/www/site;

}

}


a block for serving php (works locally):

server {

listen [server ip]:8007;
server_name "";
index index.php index.html index.htm;
root /srv/www/site;

location / {

try_files $uri $uri/ /index.php?q=$uri&$args;

}

location ~* \.php$ {

try_files $uri /index.php;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;

}

}


whenever i tried to access them through the browser i got server connection timeouts. I do not have any DNS setup with it so i was trying to access it using the server IP and port number:

[server ip]:[port]

or

[server ip]:[port]/index.html

but got nothing.


So one thing that might cause the problem is the fact that another application is being hosted on the server already. It has its own block and is running on its own port. It has its own DNS name pointing to it. But none of this should matter right? as each server block is basically a virtual server or creates a virtual domain. Accessing it through ip and port should work fine, but it aint working!

thats about all i can think of, my knowledge in this area is maxed out and i need help from smart people!

any help is greatly appreciated, thanks!


Top
   
PostPosted: Wed May 06, 2015 9:07 am 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
Some ideas:

Make sure your don't have firewall rules disallowing those non-standard ports like 8005, 8006, 8007, etc. to be used.

Try accesing those services from the linode itself, using a text mode browser like lynx.

Try using a server name other than "". You don't need DNS if you add a suitable line to your "hosts" file
(even Windows machines have a "hosts" file).


Top
   
PostPosted: Wed May 06, 2015 9:09 am 
Offline
Newbie

Joined: Wed May 06, 2015 7:10 am
Posts: 4
thanks, would i be right in saying that removing the server_name directive will still allow me to access it with the IP and Port number?

even allowing the ports using iptables doesnt seem to make a difference.


Top
   
PostPosted: Wed May 06, 2015 5:04 pm 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
if you use server_name "" then it is the same as not using any server_name line at all:

http://nginx.org/en/docs/http/request_processing.html

BTW: How do you configure nginx? Do you create files at /etc/nginx/sites-available and then
make a symlink from /etc/nginx/sites-enabled? Do you reload nginx after making changes?

What about /var/log/nginx?


Top
   
PostPosted: Thu May 07, 2015 7:24 am 
Offline
Newbie

Joined: Wed May 06, 2015 7:10 am
Posts: 4
yeh, create the config in available and symlink it in enabled, reload the server and try again.

checking the error logs at var/log/nginx, i see this: http://i.imgur.com/BORWW0F.jpg

nothing in the access logs

'Already in use' doesn't really make sense as netstat tells me that nginx is listening to those ports.

its hardly something to do with some sort of setting somewhere thats telling nginx to only allow traffic coming into this IP to go to one port and one domain?


Top
   
PostPosted: Thu May 07, 2015 10:00 am 
Offline
Newbie

Joined: Wed May 06, 2015 7:10 am
Posts: 4
i should mention that the live application on this server running on port 80, its working fine. when setting my simple server block to listen to port 80, it actually works!

results of - lsof -i :80

http://i.imgur.com/f6WbR7y.png

does '*:http' mean that port 80 is assigned to listen to all http trafic?


Top
   
PostPosted: Thu May 07, 2015 2:30 pm 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
If your server blocks do not conflict at each other, make sure you don't have several daemons (nginx, varnish, apache) trying to listen on the same port. "Address already in use" is what happens for example when you have varnish on port 80 and tell nginx to listen on port 80 as well.

You seem to have something already on port 8006. What is it?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group