Docker-compose配置nginx并配置ssl

Nginx的docker-compsoe文件

version: "3"
services:
 nginx:
  restart: always
  container_name: nginx
  image: nginx
  ports:
   - 80:80
   - 443:443
  volumes:
   - /usr/local/docker/nginx/conf.d:/etc/nginx/conf.d
   - /usr/local/docker/nginx/log:/var/log/nginx
   - /usr/local/docker/nginx/wwww:/var/www
   - /usr/local/docker/nginx/etc/letsencrypt:/etc/letsencrypt
   - /usr/local/docker/nginx/html:/usr/share/nginx/html
   - /usr/local/docker/nginx/cert:/etc/nginx/ssl

在usr/local/docker/nginx/conf.d/default.conf下修改default

server {
    listen       80;
    listen      443 ssl;
    server_name localhost;
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    #ssl on;
    ssl_certificate         ssl/xxxxx.crt;
    ssl_certificate_key     ssl/xxxxx.key;
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;
    ssl_protocols  SSLv2 SSLv3 TLSv1.2;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;

#    location / {
#                       proxy_next_upstream http_502 http_504 error timeout invalid_header;
#                       proxy_set_header Host  $host;
#                       proxy_set_header X-Real-IP $remote_addr;
#                       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#                       types {}
#                       proxy_pass http://ip:port;
#       }


location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_pass http://xxxxx:4567;
 }


#error_page  404              /404.html;


# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  404 /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;
#}

你可能感兴趣的:(Docker-compose配置nginx并配置ssl)