Alex
Alex

Reputation: 141

Nginx url GET parameter with proxy_pass

I get this url in my nginx server:

http://mynginx.com/proxy?url=http://target.com

And I want to proxy through that nginx server, so that it retrieves http://target.com

I am currently using this in my nginx configuration:

location /proxy {
    proxy_pass $arg_url
    proxy_set_header Host $host;
}

For some reason it response with a "502 Bad Gateway"

Can some tell what is the appropiate configuration for this problem?

And why nginx response with 502 error?

Thanks in advance.

Upvotes: 1

Views: 1169

Answers (1)

Alex
Alex

Reputation: 141

My bad, I was not using the resolver in my configuration:

location /proxy { resolver 8.8.8.8; proxy_pass $arg_url proxy_set_header Host $host; }

Upvotes: 1

Related Questions