Welcome! Log In Create A New Profile

Advanced

rewrite and proxy_pass at the same time in nginx

November 18, 2013 03:55PM
HI guys. I am trying to make something to work in nginx but I have no luck. I posted in StackOverflow, and no answer.
I wish any of you can help me. I paste the SO question here as well:

I am using nginx and I need a proxy to redirect some service. From my application, I should be able to do a POST, for example, to this URL: http://localhost:8776/specialService/aserverthatlistens.com/serviceToCall. And I need to rewrite it like this: https://aserverthatlistens.com/serviceToCall (notice that this URL is HTTPS, not HTTP).

I know I can use rewrite but I don't know how to use proxy_pass also, because the url of the proxy_pass should be what I rewrote...

Notice that I cannot know in advance what is the final url (aserverthatlistens.com in this example), so I always need to get it form the URL. I could send it as parameter if that help instead of being part of the URL.

So far my server configuration looks like this:

server
{
listen 8776;
server_name localhost;

access_log /var/log/nginx/tunnel.log;
error_log /var/log/nginx/error.log info;

location ~ ^/someService(/.*)$ {
proxy_pass https://$1;

}

}
Subject Author Posted

rewrite and proxy_pass at the same time in nginx

marianopeck November 18, 2013 03:55PM

Re: rewrite and proxy_pass at the same time in nginx

Francis Daly November 18, 2013 05:56PM

Re: rewrite and proxy_pass at the same time in nginx

marianopeck November 18, 2013 09:17PM

Re: rewrite and proxy_pass at the same time in nginx

marianopeck November 18, 2013 09:29PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 119
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