您的位置:首页 > 科技 > IT业 > nginx的docker-compose文件

nginx的docker-compose文件

2024/12/23 7:54:14 来源:https://blog.csdn.net/Richardlygo/article/details/140575291  浏览:    关键词:nginx的docker-compose文件

搜索   Docker之docker-compose单机编排,有模版


version: '3.5'services:nginx:image: nginx:latestrestart: alwaysvolumes:- ./html:/usr/share/nginx/html- ./conf/nginx.conf:/etc/nginx/nginx.conf- ./conf/conf.d:/etc/nginx/conf.d- ./logs:/var/log/nginxports:- "80:80"

nginx.conf


worker_processes  1;
events {worker_connections  1024;
}
http {include       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" $request_time $upstream_response_time ';sendfile        on;keepalive_timeout  65;gzip  on;fastcgi_buffers 8 128k;include conf.d/*.conf;
}

conf.d/demo.conf


upstream backendserver{server 192.168.22.3:8080;
}
upstream backendserver2{server 192.168.22.2:8080;
}
server {listen       80;listen 443 ssl;server_name  demo.xx.com;index index.html;root /usr/share/nginx/html/demo.xx.com;client_max_body_size 100M;ssl on;  ssl_certificate  /etc/nginx/conf.d/cert/demo.xx.com/demo.xx.com.pem;ssl_certificate_key  /etc/nginx/conf.d/cert/demo.xx.com/demo.xx.com.key;ssl_session_timeout 5m;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_ciphers on;  if ($scheme = http) {return   301 https://$host$request_uri;}location ~* \.html$ {root /usr/share/nginx/html/demo.xx.com;add_header Cache-Control no-store;add_header X-Frame-Options SAMEORIGIN;}location = /{root /usr/share/nginx/html/demo.xx.com;add_header Cache-Control no-store;add_header X-Frame-Options SAMEORIGIN;}location ^~ /api {proxy_connect_timeout 3000;proxy_send_timeout  3000;send_timeout 3000;proxy_read_timeout 3000;proxy_set_header   Host $http_host;proxy_set_header   X-Forwarded-Proto $scheme;proxy_set_header   X-Real-IP         $remote_addr;proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://backendserver;}location / {root /usr/share/nginx/html/demo.xx.com;try_files  $uri $uri/  @backend;}location @backend {proxy_connect_timeout 3000;proxy_send_timeout  3000;send_timeout 3000;proxy_read_timeout 3000;proxy_set_header   Host $http_host;proxy_set_header   X-Forwarded-Proto $scheme;proxy_set_header   X-Real-IP         $remote_addr;proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://backendserver2;}access_log  /var/log/nginx/demo.xx.com.access.log main; error_log   /var/log/nginx/demo.xx.com.error.log  ; }

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com