Welcome! Log In Create A New Profile

Advanced

Simple reverse proxy - 520 bad gateway

Posted by Jason In North Hollywood 
Jason In North Hollywood
Simple reverse proxy - 520 bad gateway
March 16, 2017 03:50AM
Trying to do a simple proxy from sub.domain.com/link1 to another server on
the LAN - 10.1.1.1:8080/someotherlink1.

This is what my server context looks like: (I modified the default
nginx.conf)

server {
listen 80 default_server;
listen [::]:80 default_server;
server_name sub.domain.com;
root /;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;

location /link1 {
proxy_pass http://10.1.1.1:8080/link2
}
}

`

but visiting a webpage is just loading the nginx 502 bad gateway page.

Error in the log is:

2017/03/15 22:04:27 [crit] 8647#0: *11 connect() to 10.1.1.1:8080 failed
(13: Permission denied) while connecting to upstream, client:
112.xxx.xxx.xxx, server: sub.domain.com, request: "GET /link1/ HTTP/1.1",
upstream: "http://10.1.1.1.1:8080/link2/";, host: "sub.domain.com"

whats a bit strange looking is the GET /link1/ - as this this should not be
the link in the final upstream URL - it should not be trying to get this
link.

What am I doing wrong?

Thanks,

Jason
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: Simple reverse proxy - 520 bad gateway
March 16, 2017 02:10PM
Hello!

On Thu, Mar 16, 2017 at 10:39:19AM +0800, Jason In North Hollywood wrote:

[...]

> Error in the log is:
>
> 2017/03/15 22:04:27 [crit] 8647#0: *11 connect() to 10.1.1.1:8080 failed
> (13: Permission denied) while connecting to upstream, client:
> 112.xxx.xxx.xxx, server: sub.domain.com, request: "GET /link1/ HTTP/1.1",
> upstream: "http://10.1.1.1.1:8080/link2/";, host: "sub.domain.com"
>
> whats a bit strange looking is the GET /link1/ - as this this should not be
> the link in the final upstream URL - it should not be trying to get this
> link.

The "request: ..." string in the error message is the original
request as got from the client. It is to be used to identify the
original request which caused the error.

The upstream server and corresponding URI can be found in the
"upstream: ..." string in the error message.

--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Jason In North Hollywood
Re: Simple reverse proxy - 520 bad gateway
March 17, 2017 02:40AM
Hi Maxim - Thanks!
I found my error - even though I had SELinux on permissive, it was still
blocking. I though permissive allowed, but with logging.
BR

On Thu, Mar 16, 2017 at 9:06 PM, Maxim Dounin <[email protected]> wrote:

> Hello!
>
> On Thu, Mar 16, 2017 at 10:39:19AM +0800, Jason In North Hollywood wrote:
>
> [...]
>
> > Error in the log is:
> >
> > 2017/03/15 22:04:27 [crit] 8647#0: *11 connect() to 10.1.1.1:8080 failed
> > (13: Permission denied) while connecting to upstream, client:
> > 112.xxx.xxx.xxx, server: sub.domain.com, request: "GET /link1/
> HTTP/1.1",
> > upstream: "http://10.1.1.1.1:8080/link2/";, host: "sub.domain.com"
> >
> > whats a bit strange looking is the GET /link1/ - as this this should not
> be
> > the link in the final upstream URL - it should not be trying to get this
> > link.
>
> The "request: ..." string in the error message is the original
> request as got from the client. It is to be used to identify the
> original request which caused the error.
>
> The upstream server and corresponding URI can be found in the
> "upstream: ..." string in the error message.
>
> --
> Maxim Dounin
> http://nginx.org/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login