文章来源:https://www.cnblogs.com/hello-tl/p/9293568.html
1.拉取镜像
docker pull nginx:1.13.0
2. /data/nginx1.13.0/nginx.conf/nginx.conf 配置文件
mkdir /data mkdir /data/nginx mkdir /data/nginx/nginx.conf vim /data/nginx/nginx.conf/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; include /etc/nginx/conf.d/*.conf; }
3. /data/nginx1.13.0/conf.d 配置文件
mkdir /data/nginx1.13.0/conf.d
server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; proxy_pass http://elec-gateway:4000; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1: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; #} gzip on; gzip_static on; gzip_comp_level 2; gzip_http_version 1.0; gzip_proxied any; gzip_min_length 1100; gzip_buffers 16 8k; gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; # Disable for IE < 6 because there are some known problems gzip_disable "MSIE [1-6].(?!.*SV1)"; # Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6 gzip_vary on; }
4.配置启动
docker run --name nginx1.13.0 --restart always -p 80:80 -v /data/nginx1.13.0/html:/usr/share/nginx/html -v /data/nginx1.13.0/nginx.conf/nginx.conf:/etc/nginx/nginx.conf:ro -v /data/nginx1.13.0/conf.d:/etc/nginx/conf.d -d nginx
5.说明
1、第一行指定名称和端口 2、第二行自定义页面内容 3、第三行和第四行都是指定配置信息 4、文件的路径就是刚刚复制文件夹的路径
文章来源:https://www.cnblogs.com/hello-tl/p/9293568.html
原文地址:https://www.cnblogs.com/hello-tl/p/9293568.html
时间: 2024-11-05 18:54:40