docker-nginx部署

docker-nginx部署nginx-docker拉取、配置、启动

大家好,欢迎来到IT知识分享网。docker-nginx部署"

系列文章目录


前言

Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。本文介绍如何在docker下部署nginx。


一、准备docker

拉取nginx docker

 docker pull nginx
 docker  images 

二、配置nginx

1.配置

创建配置目录:

 mkdir -p /opt/nginx/config/conf.d
 mkdir -p /opt/nginx/logs
 mkdir -p /opt/nginx/www

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; } 

default.conf配置:

 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;
    }

    #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;
    #}
}

2.启动

docker启动命令:

 docker run \
    --name nginx1.15 \
    -p 8100:80 \-v  /opt/nginx/config/nginx.conf:/etc/nginx/nginx.conf \
    -v /opt/nginx/config/conf.d:/etc/nginx/conf.d  \
    -v /opt/nginx/logs:/var/log/nginx \
    -v /opt/nginx/www:/usr/share/nginx \
    -d c13521676580

总结

本讲解docker环境下部署nginx,主要包含nginx docker拉取、配置、启动。

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/11321.html

(0)

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信