Nginx can use its reverse proxy function to implement load balancing, and can also use its forward proxy function to set up a proxy server. For example, in an intranet environment, run nginx as a proxy server on a machine that can connect to the Internet. Other machines can connect to the Internet through this machine by setting its IP and port. This article uses the official nginx image, and the proxy server can be easily implemented through the following steps. Step 1: Start nginx [root@devops ~]# docker run -p 8888:8888 --name proxy-nginx -d nginx c7baab8ea9da0a148aa9bcc1295a54391906f6be94efca7189df23ceecdbf714 [root@devops ~]# Step 2: Set up nginx Enter the container
update apt-get
Set up nginx.conf Add the following content to achieve the simplest proxy function resolver 8.8.8.8; server { listen 8888; location / { proxy_pass http://$http_host$request_uri; } } The rest of the information is the confirmed content of nginx.conf and has not been modified. # cat nginx.conf user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; resolver 8.8.8.8; server { listen 8888; location / { proxy_pass http://$http_host$request_uri; } } include /etc/nginx/conf.d/*.conf; } # Step 4: Set up the client Set the server IP and the above port 8888 on the client, and you can connect to the network through the proxy server. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: Detailed explanation of MySQL 5.7.9 shutdown syntax example
>>: Use Javascript to develop sliding-nav navigation plug-in with sliding bar effect
background There is a Tencent Linux cloud host, o...
MySQL is a commonly used open source database sof...
After installing wamp for the first time, all ser...
This article example shares the specific code of ...
CSS attribute selectors are amazing. They can hel...
A major feature of the WeChat 8.0 update is the s...
Table of contents Preface 1. What are Mixins? 2. ...
In daily work, we sometimes run slow queries to r...
1. Change the transparency to achieve the gradual...
Case 1: Last submission and no push Execute the f...
If you are a software developer, you must be fami...
Table of contents 1. What is Pinia? 2. Pinia is e...
In this note, we briefly describe What is the B+T...
A design soldier asked: "Can I just do pure ...
Here we mainly use spring-boot out of the box, wh...