Thursday, 25 October 2018

NGINX default site works, but one on another port does not

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;
  }
}



from NGINX default site works, but one on another port does not

No comments:

Post a Comment