proxy http requests to different port numbers?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

proxy http requests to different port numbers?

xt3627216
Hello,
I have several http services in the host using different port numbers, for
example one REST service listening on 8080, another on 8086. Presently VPN
is filtering out all those requests, the only port number allowed for HTTP
is 80. Looking for workaround: are there any available proxy modules (
specifically interested in ngnx) that would allow to map request urls to
different port numbers? So that, for example: request for
"http://myserver.com/rest1/api/index.html" would be forwarded to
"http://myserver.com:8080/api/index.html"...
Thank you

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285723,285723#msg-285723

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: proxy http requests to different port numbers?

Francis Daly
On Thu, Sep 26, 2019 at 02:40:55PM -0400, lvic4594 wrote:

Hi there,

> Looking for workaround: are there any available proxy modules (
> specifically interested in ngnx) that would allow to map request urls to
> different port numbers? So that, for example: request for
> "http://myserver.com/rest1/api/index.html" would be forwarded to
> "http://myserver.com:8080/api/index.html"...

That sounds like what nginx's proxy_pass is for, no?

http://nginx.org/r/proxy_pass

==
  location /rest1/ {
    proxy_pass http://myserver.com:8080/;
  }
==

plus whatever extra configuration your service needs.

(It does assume that the API is happy to be reverse-proxied.)

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: proxy http requests to different port numbers?

xt3627216
Works with http but not with https: I tried to add second proxy_pass for
https

server {
        listen       443 ssl;
        server_name  _;
        ssl_certificate     my.crt;
        ssl_certificate_key my.key;
        root         /usr/share/nginx/html;
       include /etc/nginx/default.d/*.conf;

        location /rest2/ {
            proxy_pass  https://myserver.com:8444/;

For https I have "resource not found /usr/share/nginx/html/rest2/" e.g.
nginx is not trying to proxy https request....

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285723,285768#msg-285768

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: proxy http requests to different port numbers?

Francis Daly
On Tue, Oct 01, 2019 at 10:17:36AM -0400, lvic4594 wrote:

Hi there,

> Works with http but not with https: I tried to add second proxy_pass for
> https
>
> server {
>         listen       443 ssl;
>         server_name  _;
>         ssl_certificate     my.crt;
>         ssl_certificate_key my.key;

> For https I have "resource not found /usr/share/nginx/html/rest2/" e.g.
> nginx is not trying to proxy https request....

Have you any evidence (logs, "curl -v" output) that your request is
being handled in this nginx server{} block?

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: proxy http requests to different port numbers?

xt3627216
The same thing happens if i have both http and https in the same server
block, which is the only one in config:

server {
        listen       80;
        listen     443 ssl;
        server_name  _;
        ssl_certificate     myserver.crt;
    ssl_certificate_key myserver.key;
        root         /usr/share/nginx/html;
        client_max_body_size 200M;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        location /http {
            proxy_pass <a href="http://myserver:9092;">http://myserver:9092;
        }
        location /tls {
            proxy_pass  <a href="https://myserver:8444;">https://myserver:8444;
        }

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,285723,285776#msg-285776

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: proxy http requests to different port numbers?

Francis Daly
On Thu, Oct 03, 2019 at 09:14:35AM -0400, lvic4594 wrote:

Hi there,

> The same thing happens if i have both http and https in the same server
> block, which is the only one in config:

What "same thing", specifically?

What request do you make; what response do you get; what response do
you want instead?

>         include /etc/nginx/default.d/*.conf;

That line might be doing anything. What happens if you leave it out?

> location /http {
>    proxy_pass <a href="http://myserver:9092;">http://myserver:9092;

Those lines should probably each have one more "/" in them, to match
the original requirement.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx