In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to deploy nginx in Docker and modify the configuration file, the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Direct one-line command to do:
Docker run\-name nginx-health-web-pc\-d-p 6800 nginx 80\-v / usr/docker/nginx/html:/usr/share/nginx/html\ nginx
It's a pleasure to run and start ~ then suddenly the front end comes up and says, "you have to add a configuration to your nginx." by the way, it also tells you: "so-and-so used to be matched like this."
Competitive at this time you of course can not refuse, but the real configuration up to take some thought, in general, docker startup configuration, as long as the configuration file directory can be mounted out, concise and convenient, but nginx is to load a main configuration file nginx.conf, and then load the conf.d directory in the nginx.conf sub-configuration file (usually at least a default.conf file). This is a lot more troublesome than mounting a separate directory, but as long as the thinking is clear, it is not difficult.
Let's first look at the mount command:
Command to start docker
Docker run\-name myNginx\-d-p 80:80\-v / usr/docker/myNginx/html:/usr/share/nginx/html\-v / etc/docker/myNginx/nginx.conf:/etc/nginx/nginx.conf:ro\-v / etc/docker/myNginx/conf.d:/etc/nginx/conf.d\ nginx
Here are a few considerations:
(1) the first "- v" is the location of the project. Just put the project in the directory to which it is mounted.
(2) the second "- v" is the mounted main configuration file "nginx.conf". Note that there is a line "include / etc/nginx/conf.d/*.conf;" in the "nginx.conf" file, and this include points to the path of the child configuration file. Note here that the path followed by include must not make an error.
(3) the third "- v" mounts the path of the sub-configuration file in docker, which should be consistent with the path pointed to by include in (2).
(4) emphasize that nginx.conf mounts a file (docker is not recommended), while conf.d mounts a directory.
If we start it first, we can find that there is a problem because the configuration file is not yet available.
Configuration profil
The configuration file generated when we find the nginx installed by the conventional method (usually under "/ etc/nginx"), corresponding to the mount location in the above startup command, put the main configuration file nginx.conf to the corresponding location "/ etc/docker/myNginx/nginx.conf", and the subconfiguration file "default.conf" to the "/ etc/docker/myNginx/conf.d" directory.
Rerun the startup command and find that it is ready, and the files in docker can be configured at will, just like the native installation
Idea: configuration must be riveted a train of thought: the file is mounted out of the runtime should be loaded into the docker process! So it's not easy to get confused.
-separator line-
Post my profile:
Nginx.conf
User root;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; autoindex on; # gzip on; include / etc/nginx/conf.d/*.conf; client_max_body_size 100M; client_header_buffer_size 128k; large_client_header_buffers 4 128k;}
Default.conf
Server {listen 80; server_name localhost; # charset koi8-r; # access_log / var/log/nginx/log/host.access.log main; location / {root / usr/nginx/dacheng-wechat-web; # root / usr/nginx/html; index index.html index.htm; autoindex on; try_files $uri / index/index/page.html; # try_files $uri / index/map/page.html;} # error_page 404 / 404.html # redirect server error pages to the static page / 50x.html # error_page 500 502 503 504 / 50x.htl; location = / 50x.html {root / usr/share/nginx/html;} # proxy the PHP scripts to Apache listening on 127.0.0.1 location 80 # location ~. Php$ {# proxy_pass proxy_pass #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1 9000 proxy_pass # location ~. Php$ {# root html # fastcgi_pass 127.0.0.1 include fastcgi_params; 9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME / scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # # location ~ /\ .ht {# deny all #}} on how to deploy nginx in Docker and modify the configuration file to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.