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
Common comments in HTML: <!--XXXXXXXX-->, wh...
1. Background I recently made a website, uidea, w...
Declare the parameter name, type and permission y...
Table of contents 1. How to obtain different view...
This article example shares the specific code of ...
I believe that many users who make websites will ...
This article uses examples to explain the concept...
This article records the detailed tutorial for in...
HTML <div class="spinner"></di...
Table of contents Mysql master-slave synchronizat...
background Recently, I executed a DML statement d...
mysql copies the files in the data directory to r...
In daily work, we sometimes run slow queries to r...
Table of contents 1. Basic event handling 2. Send...
Today, this post lists some great examples of circ...