Download Nginx image in Docker docker pull nginx docker images Create a mount directory mkdir -p /data/nginx/{conf,conf.d,html,logs} Write the nginx.conf configuration file and put it in the folder # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { 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; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80 default_server; listen [::]:80 default_server; server_name 182.254.161.54; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://pic; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } upstream pic{ server 182.254.161.54:8088 weight=5; server 182.254.161.54:8089 weight=5; } } Start the container Copy the code as follows: docker run --name mynginx -d -p 82:80 -v /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /data/nginx/logs:/var/log/nginx -d docker.io/nginx View the started container docker ps Previously, two tomcats have been deployed in Docker, one is port 8088 and the other is port 8089, and simple pages have been written in the two containers. Access port 8088 Access port 8089 Now we use Nginx to access the contents of the two tomcats to achieve load balancing. For the sake of difference, the load balancing function can be better reflected. The contents of the two pages are different, but the access paths are the same. We just use Nginx reverse proxy to access them in rotation. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Installation method of MySQL 5.7.18 decompressed version under Win7x64
>>: A simple way to change the password in MySQL 5.7
A dynamic clock demo based on Canvas is provided ...
Introduction: When using MySQL to create a table,...
Development Background: Recently, I am working on...
background I want to check the webpack version, b...
Error message: user: 'root' host: `localh...
Block-level element features : •Always occupies a ...
Check the transaction isolation level In MySQL, y...
Record the problem points of MySQL production. Bu...
This article shares the specific code of js to im...
Table of contents Makefile Makefile naming and ru...
This article will discuss these 4 principles as t...
Table partitioning is different from database par...
Nowadays, copying websites is very common on the I...
This article introduces how to build a high-avail...
In daily website maintenance and management, a lo...