In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to install and configure nginx in Docker. I hope you will get something after reading this article. Let's discuss it together.
Download the Nginx image from Docker
Docker pull nginxdocker images
Create a mount directory
Mkdir-p / data/nginx/ {conf,conf.d,html,logs}
Write a nginx,conf configuration file and put it in a 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 500502 503504 / 50x.html; location = / 50x.html {} upstream pic {server 182.254.161.54 server 8088 weight=5; server 182.254.161.54 server 8089 weight=5;}}
Start the container
The copy code is 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 launched container
Docker ps
Previously, we have deployed two tomcat in Docker, one is port 8088 and the other is port 8089, and we have written simple pages in two containers.
Access port 8088
Access port 8089
Now access the content of the two tomcat through Nginx to achieve the function of load balancing. Because of the difference, it can better reflect the function of load balancing. The content of the two pages is different, but the access path is the same, only through the Nginx reverse proxy to rotate access.
After reading this article, I believe you have a certain understanding of "how to install and configure nginx in Docker". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.