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
Preface: This article is based on the experience ...
Have you ever encountered a situation where we hav...
Table of contents vue custom directive Global Dir...
Prerequisites: Docker is already installed 1. Fin...
Possible reasons: The main reason why Seata does ...
Kernel: [root@opop ~]# cat /etc/centos-release Ce...
When it comes to switching directories under Linu...
This article shares the specific code of jQuery t...
1: If you use the tag <a> to link to a page,...
Table of contents Preface Single file components ...
As more and more Docker images are used, there ne...
Two cases: 1. With index 2. Without index Prerequ...
Previously, we all used files with the suffix .ms...
This article example shares the specific code of ...
I think everyone often worries about finding pict...