How to port forwarding/tunneling TCP on Nginx - nginx

I am using nginX
nginx version: nginx/1.4.6 (Ubuntu)
I have an app listening TCP on IPv4 port besides 80.
How I can to proxy/forward from domain on TCP 80 to this port.
What keywords should I find or nginx configurations?
Thanks

I think what you need is reverse proxy
Here is great tutorial how to forward connection from nginx to apache
This tutorial shows how to forward connection from nginx on port 80 to apache on port 8080

There are some options:
You can use ssh-forwarding:
plink <ssh user>#<server_ip> -pw <ssh pass> -L 0.0.0.0:<external port>:<target ip in internal network>:<target port in internal network>
Create VPN by OpenVPN for example
Check here - https://unix.stackexchange.com/questions/290223/how-to-configure-nginx-as-a-reverse-proxy-for-different-port-numbers

Related

How to make ngrok client listen a specific hostname instead of localhost?

My yaml config is like this:
yarn:
hostname: "ngrok.xfl.me:810"
remote_port: 810
proto:
tcp: 8088
My purpose is:
Forwarding https://ngrok.xfl.me:810-> 192.168.0.104:8088
But by default, as the config above, ngrok client just listen to 127.0.0.1. So it failed to connect.
How can I make the ngrok client listen to a certain hostname 192.168.0.104 instead of localhost
Thanks a lot!
It was solved with:
yarn:
hostname: "ngrok.xfl.me:810"
remote_port: 810
proto:
tcp: 192.168.0.104:8088

why nginx can not redirect request to port 80 on VPS?

I run 3 servers on VPS But nginx can not connect to server that run in port 80.
nginx can connect another port.
Does anyone know?
Nginx cannot connect to the 80 port if this port is using by another application like Apache, NodeJs ... to further info can you show your nginx error log from systemctl ?

HTTP request to VM

I have a jetty server running under port 8080 on VM. VM in its turn runs on remote server under port 10000. Is it legit to address it as http://someremote.org:10000:8080/request? Or should I use SSH somehow?
What I was looking for is called ssh tunneling. You make a tunnel from your port to remote's machine port like that:
ssh -p 10000 -L 18080:localhost:8080 user#remote.host.org
18080 here is port, that you use on your local machine in order to get to remote's 8080 port.

How do I use squid as default gateway

I have installed CentOS 6.5
my default gateway in my infrastructure is 192.168.3.1 (which is firewall IP)
I wanted to change it to the CentOS server IP So that I can limit the usage of the Internet and monitor the Websites used in my network.
I dont want to setup proxy server setting in browser
Appreciate all :)
You have two options:
First option use iptables firewall and redirect trafic from port 80 to port 3128.
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3128
Second option configure squid to lisaning port 80 instead 3128
By default, Squid listens on port 3128. If you would like to use a different port, modify
/etc/squid/squid.conf
http_port 80
save
service squid restart

Linux squid proxy configuration

I have 3 virtual machines. I have Squid proxy installed on one of them which functions as a router. I need to configure it to accept HTTP requests from only one of the other 2 machines(IP - 172.16.2.2). The change I made to the squid.conf file is:
http_port 172.16.2.2:3128
I then changed the firewall rule in the route machine so that it redirects traffic from 172.16.2.2 bound for 80 (HTTP port number) to the default squid port 3128. The command is given below:
sudo iptables -A PREROUTING -t nat -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
Machine 172.16.2.2 is connected to the router on eth1. However, whenn I am making sending a HTTP request from 172.16.2.2, I get a 403 Forbidden error. It says:
X-Squid-Error: ERR_ACCESS_DENIED 0
I can't understand it. Please help.
(edited for style)
http_port is used to configure where squid is listening for request, so if you include an ip address, it should be configured in the same machine that is listening. So, in your case 172.16.2.2 (the "other" machine) is not a correct configuration.

Resources