0

I have a production server, and I have made an important update to the project, so I decided to deploy the new updates to a separate server to test it first on another port at the same production server, but it didn't work..

I tried to set port 9090 to point for my testing server, but then I get:

http://example.com:9090/

This webpage is not available

Any idea?

Here is my blocks:

testing server:

server {
    listen 9090;
    server_name tree;
    root /home/forge/tree/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/tree-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

production server:

server {
    listen 80 default_server;
    server_name default;
    root /home/forge/default/public;

    # FORGE SSL (DO NOT REMOVE!)
    # ssl_certificate;
    # ssl_certificate_key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/default-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

the error is:

2015/11/19 17:42:16 [error] 2878#0: *60 FastCGI sent in stderr: "PHP message: PHP Deprecated:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0" while reading response header from upstream, client: 46.185.165.167, server: default, request: "POST /api/get-country-tree?country_id=-1&level=3 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "kalimon.info", referrer: "http://kalimon.info/new_tree"

edit

$ netstat -antp
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      18539/nginx: worker
tcp        0      0 0.0.0.0:9090            0.0.0.0:*               LISTEN      18539/nginx: worker

$ wget localhost:9090
--2015-11-22 11:26:57--  http://localhost:9090/
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:9090... connected.
HTTP request sent, awaiting response... 403 Forbidden
2015-11-22 11:26:57 ERROR 403: Forbidden.

edit 2

I have fixed the permission error by:

$ chmod -R 775 ~/tree

Now I get response... 200:

$ wget 0.0.0.0:9090
--2015-11-22 12:17:47--  http://0.0.0.0:9090/
Connecting to 0.0.0.0:9090... connected.
HTTP request sent, awaiting response... 200 OK

but in the browser, I still get the error ERR_CONNECTION_REFUSED

edit 3

Ok, I am getting closer to the answer:

$ nmap localhost

Starting Nmap 6.40 ( http://nmap.org ) at 2015-11-22 13:27 AST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00040s latency).
Not shown: 995 closed ports
PORT     STATE SERVICE
22/tcp     open  ssh
80/tcp     open  http
9090/tcp   open  zeus-admin
3306/tcp   open  mysql
5432/tcp   open  postgresql

So, port 9090 is not using http service like port 80, is this the problem? how to solve this?

I tried port 96 but its not listed when using nmap localhost, and I get ERR_CONNECTION_TIMED_OUT

So, I can connect locally only, but when using a browser, I get ERR_CONNECTION_TIMED_OUT how to properly open the port?

  • What does the log files say? Did you restart/reload nginx after the changes? – Sven Nov 19 '15 at 14:08
  • Which file please to check? – simo Nov 19 '15 at 14:28
  • 2
    As dumb as it sounds, is port 9090 opened on your testserver? As this is no standard port and should be closed by a basic firewall setup. – Flatron Nov 19 '15 at 15:11
  • 1
    @simo The 403 clearly indicates that your requests are reaching a web server. Most likely they are reaching the correct web server, but you can check the server logs if you want to be absolutely sure. The server logs may also tell you why the server is producing a 403. – kasperd Nov 22 '15 at 8:50
  • 1
    Since 403 is an error code, I expect it to have been logged in the error log. Since your two server stanzas are using different error logs, you should be able to figure out which server stanza it was processed by simply by identifying which of the two log files it was logged in. Given that the only other differences between the two server stanzas are listen, server_name, and root I guess the problem is permissions on the directory you used as your server root. – kasperd Nov 22 '15 at 8:55
1

Thanks to every body who tried to support, the solution was as simple as:

sudo ufw allow [port number]

I didn't know that I have to open the port by my self!

| improve this answer | |
0

The error says 403 - forbidden, make sure that Nginx user can read from your webroot (/home/forge/tree/public) and if SELinux is enabled you will have to also add this port to allow access:

semanage port -a -t http_port_t -p tcp 9090
| improve this answer | |
  • If I execute your comman, I get error: ValueError: SELinux policy is not managed or store cannot be accessed. please check edit 2 above – simo Nov 22 '15 at 9:23
  • Have you checked the error log, try also with different web browser. – HTF Nov 22 '15 at 9:53
  • there are no errors, I think that port 9090 is not opened to the world? how would I check this? I can only connect to the server in the terminal as in the edit above – simo Nov 22 '15 at 10:20
  • please check edit 3 – simo Nov 22 '15 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.