Hello I am using nginx to set up two servers. one being a frontend port 80 and one being a backend port 8080 on one IP address.
The default one works, the backend through port 8080 gives me a Connection Timeout/ No response when trying to access the server.
I think it is my execution however, to test backend, I have a simple index.php that should come up if i go to xxx.xxx.xxx.xxx:8080 in a browser, except i get a connection time out / no response.
Nginx says it is open and listening. without the port number it goes to my frontend/default server for this ip address.
Error logs show nothing! Even the logs in my server blocks with access and upstream show nothing.
ubuntu 18.04
here is my config server 1 port 80 default
server {
# Replace this port with the right one for your requirements
listen 80 default_server;
# Multiple hostnames separated by spaces. Replace these as well.
server_name www.domain.com domain.com *.domain.com;
root /var/www/my_project/html;
error_page 404 errors/404.php;
# access_log logs/my_project.ventures.access.log;
access_log /var/log/nginx/server.intra-upstream.log upstream buffer=16k;
access_log /var/log/nginx/server.intra-access.log combined buffer=16k;
index index.php index.html index.htm;
# static file 404's aren't logged and expires header is set to maximum age
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
# By all means use a different server for the fcgi processes if you need to
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
}
This is the second server that cannot be accessed via client.domain2.com or www.domain2.com - URL is correct, but shows server 1 htdocs instead. client.domain2.com:8080 or any other combination brings Cannot reach site or Connection Timed out
server {
# Replace this port with the right one for your requirements
listen 8080;
# Multiple hostnames separated by spaces. Replace these as well.
server_name client.domain2.com www.domain2.com;
root /var/www/my_project/backend;
error_page 404 errors/404.php;
# access_log logs/my_project.fun.access.log;
access_log /var/log/nginx/server.intra-upstream.log upstream buffer=16k;
access_log /var/log/nginx/server.intra-access.log combined buffer=16k;
index index.php index.html index.htm;
# static file 404's aren't logged and expires header is set to maximum age
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_intercept_errors on;
# By all means use a different server for the fcgi processes if you need to
fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
}
you must to be allow your 8080 port in firewall
If you're not installed ufw install it like
$ sudo apt install ufw
Then check the ufw status
$ sudo ufw status
Check your needed port is added into the list.
then use
$ sudo ufw allow 8080
then check the ufw status again. now it show you the allowed ipv4, ipv6 ports and connections. Restart your nginx server and check the port is working
$ sudo systemctl nginx restart
$ curl -I 'http://{youraddress}:8080'
Or hit the url in your browser.
If you are using GCP, AWS check the external firewall settings in your server console. like http_server allow 80. and edit this record to 80, 8080 and save it.
Caution: Don't do the internal firewall settings using ufw in GCP, AWS because already they have their own firewall settings for the engines.
Thank you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With