Dockernginx reverse proxy

Source: Internet
Author: User
Dockernginx reverse proxy Write docker-compose.yml

Nginx:
Image: 17daebd00e2c
Ports:
-80: 80
Volumes:
-/Home/conf/nginx. conf:/etc/nginx. conf
Links:
-Nginx1
-Nginx2
Privileged: true

Nginx1:
Image: 17daebd00e2c
Volumes:
-/Home/www1:/usr/share/nginx/html
Privileged: true

Nginx2:
Image: 17daebd00e2c
Volumes:
-/Home/www2:/usr/share/nginx/html
Privileged: true

Compile nginx. conf

Add

Upstream pro {
Ip_hash; // access by ip address, which can be annotated during testing
Server nginx1: 80;
Server nginx2: 80;
}

Add

Location /{
Proxy_pass http: // pro;
# Proxy_redirect off;
# If the port is not port 80, set it to Host $ host: port number to transmit the user information received by the proxy server to the real server.
Proxy_set_header Host $ host;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
Client_max_body_size 10 m;
Client_body_buffer_size 128 k;
Proxy_connect_timeout 300;
Proxy_send_timeouts 300;
Proxy_read_timeout 300;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
Add_header Access-Control-Allow-Origin *;

}

Add the html file to the www1 and www2 directories.

Access the html address directly.

Nginx1 and nginx2 can only be accessed in the docker container

The above is the details of the docker nginx Reverse proxy. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.