Docker安装Nginx

#docker pull nginx:latest
(第一次启动Docker-Nginx)
#docker run --detach \
    --publish 80:80 \
    --restart always \
    --volume /data/nginx/html:/usr/share/nginx/html:ro \
    --volume /data/nginx/conf.d:/etc/nginx/conf.d:ro \
    --volume /data/nginx/logs/:/var/log/nginx \
    --volume /etc/localtime:/etc/localtime \
    nginx:latest

停止Docker的Nginx

#docker stop ee6646198d59

删除Docker的Nginx容器

#docker rm ee6646198d59

修改nginx.conf文件

Docker安装Nginx(含:Windows启动、重启、停止)
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
  
    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;   #关闭显示nginx版本

    server_names_hash_bucket_size 64;
    # server_name_in_redirect off;


    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;
   # ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_ciphers "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384:TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off; # Requires nginx >= 1.5.9
    # ssl_stapling on; # Requires nginx >= 1.3.7
    ssl_stapling_verify on; # Requires nginx => 1.3.7

    ##
    # Log Settings
    ##

    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;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_vary on;
    gzip_min_length 1k;
    gzip_buffers 4 32k;
    gzip_disable "msie6";
    gzip_disable "MSIE [1-6].";
    gzip_http_version 1.1;
    gzip_comp_level 3;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/javascript application/json;
    ##
    # Proxy Headers
    ##

    include /etc/nginx/conf.d/*.conf;

   ##
    # filter ip
    ##
    include /etc/nginx/blocksip.conf;  #过滤IP地址

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*.conf;  #配置各个站点的信息


}
nginx.conf

相关文章: