Redirect incoming request to new port
November 29, 2022 02:40AM
Hi,

I need to do redirect/reroute a request to a node app on a different port to the default http request.

This worked with Apache - RewriteRule ^(.*)/hooks$ http://127.0.0.1:3000/$1 [P,L]

How do I implement a similar rewrite in nginx?

Do I use location {} or listen on the specified port?

Not too sure where to start. Any great tutorials welcome.

Thanks

Dion
Re: Redirect incoming request to new port
December 01, 2022 06:44AM
I just used the following to access a local video encoder stream externally. I can now view the stream with <external_ip>/ts

location /ts {
proxy_pass http://<local_ip>/0.ts;
}
Re: Redirect incoming request to new port
December 03, 2022 04:33PM
I got it working. I just misunderstood how routing worked. I was sending the whole path to the node.js app instead of the /hooks route only for example.

Thank you
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 99
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready