Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx proxy all traffic to remote nginx

I have 2 servers,

  1. with IP xx.xx.xx.xx, situated in Germany ... (running frontend: nginx(static content), backend: Apache2)

  2. with IP yy.yy.yy.yy, situated in Italy...

All requests at the moment is sending to server with IP xx.xx.xx.xx, How can I proxy all traffic from xx.xx.xx.xx to yy.yy.yy.yy using nginx ...

          request                           proxy, request Internet     ->       xx.xx.xx.xx(nginx)         ->             yy.yy.yy.yy(nginx, Apache)              <-                                  <-           response                          proxy, response 
like image 288
user676674 Avatar asked Mar 25 '11 12:03

user676674


People also ask

Can Nginx TCP proxy?

In NGINX Plus Release 5 and later, NGINX Plus can proxy and load balance Transmission Control Protocol) (TCP) traffic. TCP is the protocol for many popular applications and services, such as LDAP, MySQL, and RTMP. In NGINX Plus Release 9 and later, NGINX Plus can proxy and load balance UDP traffic.

Can I use Nginx as a forward proxy?

By using the nginx forward proxy we can masking the location and IP for gaining access to services. Nginx forward proxy will continuing the request on behalf of the client. At the time when the host server will accept the request then only we can see the IP of the nginx proxy server.

Is Nginx forward or reverse proxy?

Nginx is an open source web server that can also serve as a reverse proxy. Apart from being used to host websites, it's also one of the most widely used reverse proxy and load balancing solutions.

What is Proxy_pass?

The proxy_pass docs say: This directive sets the address of the proxied server and the URI to which location will be mapped. So when you tell Nginx to proxy_pass , you're saying "Pass this request on to this proxy URL".


1 Answers

For others. Answer for subject is configure nginx like:

server {   listen 80;   server_name mydomain.com;     location / {       access_log off;       proxy_pass http://mydomain.com:8080;       proxy_set_header X-Real-IP $remote_addr;       proxy_set_header Host $host;       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;     } } 
like image 99
Vladimir Shmidt Avatar answered Oct 03 '22 11:10

Vladimir Shmidt