docker nginx reverse proxy

大家讲道理
Release: 2023-03-07 22:18:01
Original
1806 people have browsed it

Preparationdocker-compose.yml

##nginx:

image: 17daebd00e2c
ports:
- 80:80
volumes:
- /home/conf/nginx.conf:/etc/nginx/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

Write nginx.conf

#Add

upstream pro {

ip_
hash;//According to ip access, you can Comment during testing server nginx1:80;
server nginx2:80;
}

Add

location / {

to the server module , configured as Host $host: port number, the purpose is to transmit the user information received by the proxy server to the real server
        proxy_
set_head
er                                                                                                                                                                 to be transferred to the real server.
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_ Time Out
300
;
Proxy_S ## End _ Timeout 300; Proxy_ream_timeout 300; 2K; Proxy_busy_buffers_size 64k;                 proxy_temp_
file_write_size 64k; ##Finally add html files in the www1 and www2 directories

You can directly access the html address


##nginx1 and nginx2 can only be used in docker containers Visit

The above is the detailed content of docker nginx reverse proxy. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!