Welcome! Log In Create A New Profile

Advanced

Re: Reverse proxy - variable

Francis Daly
January 15, 2019 05:00PM
On Mon, Jan 14, 2019 at 05:50:19PM -0500, cboyke wrote:

Hi there,

> I've seen this asked and answered many times - and I've tried many of the
> suggestions posted, but still not able to get this to work.

The documentation for proxy_pass is at http://nginx.org/r/proxy_pass

That says how things are intended to work when a variable is used.

> I'm reverse-proxying to an internal IP inside an AWS VPC - eventually, I'd
> like to use a JavaScript function to give the correct IP, but for now I'm
> just hard-coding it in a variable.
> I've tried all of the below, and none work:

Can you show the "curl" command that you use to make the request of nginx,
and show the response?

It is often useful to use curl instead of a full browser, because it is
likely to show something other than "spins forever" -- it may fail to
respond, or it may show a http 301 to the same url, or something else.

> server {
> listen 80;
> server_name myserver.com;
> location / {
> set $with_trailing_slash "http://172.31.17.123:8080/";
> #proxy_pass http://172.31.17.123:8080/; #this works no
> problem.
> #proxy_pass $with_trailing_slash; # This gets to the
> upstream but gives a 404;

For what it's worth,

proxy_pass http://127.0.0.1:8091;

and

set $ip 127.0.0.1:8091;
proxy_pass http://$ip;

work the same as each other for me, while

proxy_pass http://127.0.0.1:8091/;

and

set $ip 127.0.0.1:8091;
proxy_pass http://$ip/;

do not work the same as each other -- the last bullet point in the
documentation explains why that is.

> #proxy_pass $with_trailing_slash$request_uri; # This spins
> forever
> set $no_trailing_slash "http://172.31.17.123:8080";
> #proxy_pass $no_trailing_slash; #spins forever;

Do you see a difference between using "proxy_pass $no_trailing_slash;"
and "proxy_pass http://172.31.17.123:8080"?

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Reverse proxy - variable

cboyke January 14, 2019 05:50PM

Re: Reverse proxy - variable

Francis Daly January 15, 2019 05:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 286
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready