I have docker containers with my own site and I would like to create external ports 444 and 81 from docker and connect it to a user request from my domain from external nginx on my linux machine. How do I organize the nginx.example1.conf file, I created the containers, I just have to connect the ports, how can this be done in the nginx.example1.conf file and am I doing the right thing?
In short, how do I write the nginx.example1.conf file correctly?
Same as any other reverse proxy configuration for nginX
, the only difference will be that the endpoints are on localhost
This is trivial example:
server {
listen 80;
server_name foobar.net www.foobar.net test.io www.test.io;
location / {
proxy_pass http://localhost:81;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
First, expose the ports on docker (which means they will be visible and accessible from your host on the same ports) Then configure your host nginx as a reverse proxy going to localhost:444 and localhost:81 on the / requests
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.