Forum: NGINX Not listing proxy_pass port 8009

2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-23 18:39
(Received via mailing list)
Hello,

I am using Nginx web server and getting error “502 bad gateway” while
accessing some sites.
I have observed that, proxy_pass port is not listing in the server.

e.g.:- In above configuration example.com is running on port 80 and
proxy_pass localhost is running on port 8009.
Port 80 is listing perfectly but port 8009 is not listing because of
this
reason example.com is not working. Please suggest me on this.

server {
    listen        80;
    server_name example.com;

   location / {
        proxy_pass    http://localhost:8009;
        send_timeout 6000;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }
}

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241157#msg-241157
1266aa99d1601b47bbd3ec22affbb81c?d=identicon&s=25 B.R. (Guest)
on 2013-07-23 18:57
(Received via mailing list)
Your configuration means that Nginx is listening on port 80 and will
forward any request form example.com to a backend located on localhost
listening on port 8009.

Since Nginx is a proxy, you need a backend to serve content to which
requests sent to Nginx will be forwarded.

You seem not to understand what you are doing...
You machine is doing precisely what you ask it to do. Not more, not
less.
---
*B. R.*
24a9986d5a2fa4d006f22abed0b8951e?d=identicon&s=25 Richard Kearsley (Guest)
on 2013-07-23 19:03
(Received via mailing list)
the port in proxy_pass is not for listening/accepting incoming
connections - it is for connecting outwards to another server/service
You must have something else (another httpd, probably not nginx)
listening on 8009......?
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-23 20:45
(Received via mailing list)
Hello,

Thanks for the reply but when I am browsing example.com or using ip
address
getting error  " 502 bad gateway".
Please suggest me on this..

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241160#msg-241160
C951d32082407e468f009874d1bcc789?d=identicon&s=25 Miguel C. (Guest)
on 2013-07-23 20:58
(Received via mailing list)
You can't browse to the URL because there is no web application running
on port 8009.

You tell nginx to listen on port 80...so far all good.

But then you are telling nginx to proxy_pass the request to a diferent
port...
So the question is more: is this really what you want? If so... may I
ask what's supposed to be listening on port 8009?

I mean you said before that nothing is listening on port 8009... but you
want nginx to proxy the requests to that port... this makes no sense.




imran_kh <nginx-forum@nginx.us> wrote:
>Posted at Nginx Forum:
>http://forum.nginx.org/read.php?2,241157,241160#msg-241160
>
>_______________________________________________
>nginx mailing list
>nginx@nginx.org
>http://mailman.nginx.org/mailman/listinfo/nginx

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-23 21:20
(Received via mailing list)
Hello,

Thanks for the reply. I have never worked on Nginx server. So please
help me
to resolve the issue.

File /etc/nginx/nginx.conf content are as follow.

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

File /etc/nginx/sites-enabled/default contains are as follows.

server {
    listen        80;
    server_name abc.com;

   location / {
        proxy_pass    http://localhost:8007;
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen        80;
    server_name pqr.com;
    client_max_body_size 200m;
    access_log    /var/log/nginx/openerp-access.log;
    error_log    /var/log/nginx/openerp-error.log;
    #ssl on;
    #ssl_certificate        /etc/ssl/nginx/server.crt;
    #ssl_certificate_key    /etc/ssl/nginx/server.key;
    #ssl_session_timeout         5m;
    #ssl_prefer_server_ciphers    on;
    #ssl_protocols               SSLv2 SSLv3 TLSv1;
    #ssl_ciphers
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

    #send_timeout 10m;

    proxy_max_temp_file_size 0;

    client_header_timeout   10m;
    client_body_timeout     10m;
    send_timeout            10m;

    location /agromanager {
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_pass    http://localhost:8003;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }

    location /web {
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_pass    http://127.0.0.1:8005;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }

    location / {
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_pass    http://127.0.0.1:8002;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }


}

server {
    listen        80;
    server_name xyz.com;

   location / {
        proxy_pass    http://localhost:8010;
        send_timeout 6000;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }
}

Only xyz.com is working properly expect abc.com, pqr.com and also trying
browse through IP address but getting “502 bad gateway”.

Thanks,
Imran khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241162#msg-241162
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2013-07-23 22:33
(Received via mailing list)
On 23 July 2013 20:20, imran_kh <nginx-forum@nginx.us> wrote:
> Thanks for the reply. I have never worked on Nginx server. So please help me
> to resolve the issue.

You've been told what the problem is 3 times already. It's nothing to
do with nginx. The problem is that the process that nginx has been
configured *to*talk*to* on port 8009 is *not* listening on port 8009.
Fix that.

J
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 01:41
(Received via mailing list)
Hello,

Thanks for the reply,

Actually openerp is also hosted on this server. Is this create “502 bad
gateway” error? Please find the error log and suggest me on this.

#openerp-error.log
2013/07/23 18:21:15 [error] 1465#0: *196 connect() failed (111:
Connection
refused) while connecting to upstream, client: 10.10.10.10, server:
pqr.com,
request: "GET / HTTP/1.0", upstream: "http://127.0.0.1:8002/", host:
"pqr.com"

#error.log
2013/07/23 18:21:16 [error] 1465#0: *198 connect() failed (111:
Connection
refused) while connecting to upstream, client: 10.10.10.10, server:
abc.com,
request: "GET / HTTP/1.0", upstream: "http://127.0.0.1:8007/", host:
"abc.com"

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241168#msg-241168
Ebc58bc7e33667aecf6a81911edc7964?d=identicon&s=25 Nikolas Stevenson-Molnar (Guest)
on 2013-07-24 02:00
(Received via mailing list)
"502 Bad Gateway" almost always means something is wrong with the
upstream server (i.e., Nginx is working fine, whatever it's proxying to
is having problems) so look for a problem there.

_Nik
C951d32082407e468f009874d1bcc789?d=identicon&s=25 Miguel C. (Guest)
on 2013-07-24 02:08
(Received via mailing list)
The log tells you much... although has was already said the problem is
that something's wrong with whatever should be listening on those
ports...

Openerp is one of those and probably is not running or at least it's not
listening on the port specified in nginx  configuration...

In any case the problem is not in nginx...  find out what is supposed to
be listening on those ports... I doubt you will have problems with nginx
after that.



Nikolas Stevenson-Molnar <nik.molnar@consbio.org> wrote:
>>
>> "pqr.com"
>> Imran Khan.
>nginx mailing list
>nginx@nginx.org
>http://mailman.nginx.org/mailman/listinfo/nginx

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 02:21
(Received via mailing list)
Hello,

Thanks for the prompt reply.

I have scanned the listing ports in the servers. Please help me out to
fix
this issue.
I never worked on Nginx server and am totally stuck.

# sudo nmap localhost
Starting Nmap 5.21 ( http://nmap.org ) at 2013-07-23 20:15 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000018s latency).
Not shown: 991 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
80/tcp   open  http
631/tcp  open  ipp
5432/tcp open  postgresql
5666/tcp open  nrpe
8008/tcp open  http
8009/tcp open  ajp13
8090/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
# sudo nmap IP_Address

Starting Nmap 5.21 ( http://nmap.org ) at 2013-07-23 20:15 EDT
Nmap scan report for hostname (IP_Address)
Host is up (0.000019s latency).
Not shown: 992 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open  ssh
80/tcp   open  http
5666/tcp open  nrpe
8008/tcp open  http
8009/tcp open  ajp13
8080/tcp open  http-proxy
8090/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.13 seconds

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241172#msg-241172
Ebc58bc7e33667aecf6a81911edc7964?d=identicon&s=25 Nikolas Stevenson-Molnar (Guest)
on 2013-07-24 02:30
(Received via mailing list)
Note that the log entries from your previous email indicate upstream
servers on ports 8002 and 8007. According to what you've posted here,
there's nothing listening on either of those ports.

_Nik
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 02:44
(Received via mailing list)
Hello,

Correct. So how should I resolve this issue?

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241175#msg-241175
Ebc58bc7e33667aecf6a81911edc7964?d=identicon&s=25 Nikolas Stevenson-Molnar (Guest)
on 2013-07-24 03:16
(Received via mailing list)
If 8009 is the desired port, then change the upstream server in your
nginx conf to use port 8009. If 8002/8007 are the correct ports, then
change the upstream server to listen on those ports.

_Nik
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 03:36
(Received via mailing list)
Hello,

Thanks but how can I resolve the error “502 bad gateway” for IP Address?
Getting this error while browsing site using IP Address.

Thanks.
Imran khan,

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241177#msg-241177
Ebc58bc7e33667aecf6a81911edc7964?d=identicon&s=25 Nikolas Stevenson-Molnar (Guest)
on 2013-07-24 03:59
(Received via mailing list)
Are there supposed to be services running on ports 8002 and 8007? If so,
then they don't seem to actually be running and you need to fix that
(that's not nginx-related). If you actually meant to proxy to another
port(s), then look at your nginx config, find where you're proxying to
8002 and 8007 and change those to the correct ports.

_Nik
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 21:20
(Received via mailing list)
Hello,

I have observed that, Nginx configured on port 80 as per
/etc/nginx/sites-enabled/default file but it is listening on port 8080
and
80. Please see the details for the same.

server {
listen 80;
server_name example.com;

location / {
proxy_pass http://localhost:8009;
send_timeout 6000;
proxy_read_timeout 120;
proxy_connect_timeout 120;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
}
}

Port 8080 is listening on Public IP address.
# sudo netstat -anop | grep :8080
tcp        0      0 Public_IP:8080      0.0.0.0:*               LISTEN
18674/nginx      off (0.00/0/0)

Port 80 is listening on 0.0.0.0
# sudo netstat -anop | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*
LISTEN
   18674/nginx      off (0.00/0/0)

When I am trying to start the nginx service without init.d script
getting
below message.

#sudo /usr/sbin/nginx
[sudo] password for xyz:
nginx: [warn] conflicting server name " example.com " on 0.0.0.0:80,
ignored
nginx: [warn] conflicting server name " example1.com " on 0.0.0.0:80,
ignored
nginx: [warn] conflicting server name "example.com " on 0.0.0.0:80,
ignored
nginx: [warn] conflicting server name "example2.com " on 0.0.0.0:80,
ignored
nginx: [emerg] bind() to Public_IP:8080 failed (98: Address already in
use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to Public_IP:8080 failed (98: Address already in
use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to Public_IP:8080 failed (98: Address already in
use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to Public_IP:8080 failed (98: Address already in
use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to Public_IP:8080 failed (98: Address already in
use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241203#msg-241203
Ebc58bc7e33667aecf6a81911edc7964?d=identicon&s=25 Nikolas Stevenson-Molnar (Guest)
on 2013-07-24 21:37
(Received via mailing list)
Go back over all your nginx conf files, making sure to look at included
files as well... it seems that somewhere you have "listen 8080" and
possibly overlapping "server_name" directives.

If that fails, I'd suggest you backup then throw out your current
config, then start simple and build it up one piece at a time, testing
each addition. E.g., start with just a single "server" block, get it
working, then add the next one, etc. etc.

_Nik
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 22:36
(Received via mailing list)
Hello,

Thanks for the reply.

Yes you are correct. I have tried to change the port from 8080 to 80 in
/etc/nginx/conf.d/default.conf.
Browse the Public IP address and xyz.com site, getting “no handler
found”
error.

File /etc/nginx/conf.d/default.conf content as follows.
# sudo cat default.conf
## Basic reverse proxy server ##
## Apache (vm02) backend for www.example.com ##
upstream apachephp  {
      server Public_IP:8069; #Apache1
}

## Start www.example.com ##
server {
    listen       Public_IP:8080;
    #server_name  www.example.com;

    #access_log  /var/log/nginx/log/openerp;
    #error_log  /var/log/nginx/log/openerp.log;
    #root   /usr/share/nginx/html;
    #index  index.html index.htm;

    ## send request back to apache1 ##
    location / {
     proxy_pass  http://Public_IP:8069;
     #proxy_next_upstream error timeout invalid_header http_500 http_502
http_503 http_504;
     proxy_redirect off;
     proxy_buffering off;
     proxy_set_header        Host            $host;
     proxy_set_header        X-Real-IP       $remote_addr;
     proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
   }
}

File /etc/nginx/nginx.conf content as follows.

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;

        ##
        # nginx-naxsi config
        ##
        # Uncomment it if you installed nginx-naxsi
        ##

        #include /etc/nginx/naxsi_core.rules;

        ##
        # nginx-passenger config
        ##
        # Uncomment it if you installed nginx-passenger
        ##

        #passenger_root /usr;
        #passenger_ruby /usr/bin/ruby;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

File /etc/nginx/sites-enabled/default contains as follows.

server {
    listen        80;
    server_name abc.com;

   location / {
        proxy_pass    http://localhost:8007;
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }
}

server {
    listen        80;
    server_name pqr.com;
    client_max_body_size 200m;
    access_log    /var/log/nginx/openerp-access.log;
    error_log    /var/log/nginx/openerp-error.log;
    #ssl on;
    #ssl_certificate        /etc/ssl/nginx/server.crt;
    #ssl_certificate_key    /etc/ssl/nginx/server.key;
    #ssl_session_timeout         5m;
    #ssl_prefer_server_ciphers    on;
    #ssl_protocols               SSLv2 SSLv3 TLSv1;
    #ssl_ciphers
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

    #send_timeout 10m;

    proxy_max_temp_file_size 0;

    client_header_timeout   10m;
    client_body_timeout     10m;
    send_timeout            10m;

    location /agromanager {
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_pass    http://localhost:8003;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }

    location /web {
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_pass    http://127.0.0.1:8005;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }

    location / {
        send_timeout 600;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_pass    http://127.0.0.1:8002;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }


}

server {
    listen        80;
    server_name xyz.com;

   location / {
        proxy_pass    http://localhost:8010;
        send_timeout 6000;
        proxy_read_timeout 120;
        proxy_connect_timeout 120;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    }
}

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241206#msg-241206
2974d09ac2541e892966b762aad84943?d=identicon&s=25 imran_kh (Guest)
on 2013-07-24 23:51
(Received via mailing list)
Hello,

Any suggestion or advice?

Thanks,
Imran Khan.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241207#msg-241207
Ebc58bc7e33667aecf6a81911edc7964?d=identicon&s=25 Nikolas Stevenson-Molnar (Guest)
on 2013-07-24 23:59
(Received via mailing list)
That looks like an OpenERP problem: http://bit.ly/1aJm0DB

_Nik
2974d09ac2541e892966b762aad84943?d=identicon&s=25 naseeb0077 (Guest)
on 2013-07-25 02:37
(Received via mailing list)
Hello,

Thanks for the prompt reply.

I have scanned the listing ports in the servers. Please help me out to
fix
this issue.
I never worked on Nginx server and am totally stuck.

# sudo nmap localhost
Starting Nmap 5.21 ( http://nmap.org ) at 2013-07-23 20:15 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000018s latency).
Not shown: 991 closed ports
PORT STATE SERVICE
21/tcp open ftp

http://www.health.com/health/

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,241157,241212#msg-241212
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.