Nginx proxy reverse out port - nginx

I want to define out port of my nginx server.
Actually some thing like port forwatding by iptables in nginx.
Request:
Client via(ip:port) send to nginx(ip:80).
Nginx via( nginx ip:client port) send to server B(ip:80).
Response:
Server B via(ip:80) send to nginx(ip:client port).
Nginx via(ip:80)send to client(Ip:port)
I have a server running nginx on it listen to port 80.
It recives requests from client and acording to location in request, forwards it to diferent proxy servers.
Problem:
I need to nginx connects to my proxy server by port which client conects to it.
For example:
Client connects to port 80 of my nginx server via port 1000 and now I want to my nginx connects to lisetenig port of my other server via port 1000.
Forwarded Ip is no matter.
And connection protocol is tcp http.

Related

Config Nginx for getting Port in URL or Header

I have an Ubuntu virtual server where many application servers are running on different ports, I want all its inputs to be on the same domain and port. How can I configure Nginx to receive the port in the URL or header and transfer requests with all of its headers to the local port?
Example of port in URL:
domain.com/1256 -> 127.0.0.1:1256
domain.com/1256/abcd -> 127.0.0.1:1256/abcd

NGINX tcp stream on port 443

Is it possible to have nginx host a website on standard ports 80 and 443 while at the same time having it proxy a tcp stream on the same port 443 ?
In which case, how does nginx know when to route the client to the website and when to route to the stream ? It seems like tcp streams don't support the "server_name" value.
It is not possible to use both stream and http on one port. HTTP has the concept of routing based on server name while a tcp stream cannot route based on a server name.

How to configure the nginx to forward http requests to a specific localhost port through an IP Address and Resource Name?

Is there any way to configure the nginx to forward http requests to a specific localhost port through an IP address and a resource name?
For example, http://1.2.3.4/8000 request should be forwarded to http://localhost:8000.
Thanks!

Port and IP address - what does bind mean?

I read on Ports WIKI page that "Ports are logical constructs which identifies a service or process", what service or process means here? It means protocol like HTTP, FTP etc. or software applications which are configured to listen on that port?
When it is said that application is listening on so and so... then does it listen for request to an IP address or a port, or listens on a combination of port and IP address? Application listen for a specific IP address and one or more ports are bound to it OR it listens for a combination of IP and port?
For example, I can have application configured for 7001 for HTTP requests and 7002 for HTTPS requests. So, would be listening on 7001 or what?
Applications/services such as a HTTP web server or an FTP server are assigned a port to use/listen on, usually in the config of the application. and they often use a standard port. HTTP for example usually uses port 80.
If an app/service is listening it listens to a port and has no relation to a specific IP address. This is because the IP address it is listening on is the IP address of the computer that the app/service it is running on.

How to hide web application port in reverse proxy

I have use nginx for reverse proxy which listen on port 80. and I have a web application listen on port 9999, I config nginx with reverse proxy to redirect client request from port 80 to port 9999.
Now I found that when access 80 port, browser will show web application response (this is correct.), however, if browser directly access 9999 port, it will also show web application response.
So, How can I configure nginx that browser can only access port 80, not port 9999. Thanks!
i will recommend you two solutions:
You can bind your application to listen on localhost:9999 rather than *:9999
you can edit your firewall to don't allow traffic for 9999 port and only allow for port 80. for that you can edit iptables by going to /etc/sysconfig/iptables

Resources