Docker 部署 Nginx 时,配置文件 nginx.conf 中引用 conf.d 目录下的 default.conf 文件失效。
```usernginx;
worker_processesauto;
error_log/var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections1024;
}
http {
include /etc/nginx/mime.types;
default_typeapplication/octet-stream;
log_formatmain'$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.logmain;
sendfile on;
client_max_body_size 100M;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout65;
types_hash_max_size2048;
gzip on;
gzip_min_length 1k;
gzip_comp_level 2;
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;
gzip_vary on;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_namelocalhost;
location / {
root /usr/share/nginx/html;
indexindex.html index.htm;
}
error_page404 /404.html;
location = /404.html {
internal;
}
error_page 500 502 503 504/50x.html;
location = /50x.html {
internal;
}
}
}
server {
listen 80;
listen [::]:80;
server_name xx.cn;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name xx.cn;
ssl_certificate xxx.pem;
ssl_certificate_key xx.key;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
location /blog/ {
proxy_pass http://localhost:11102/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
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 $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
}
location /status/ {
proxy_pass http://localhost:3001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
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 $scheme;
}
location = /favicon.ico {
access_log off;
log_not_found off;
}
location /files/ {
charset utf-8;
#allow 124.64.18.162;
#deny all;
root /home/meta/;
autoindex on;
}
# 错误页面配置
error_page 404 /404.html;
location = /404.html {
internal;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
internal;
}
}
```
页:
[1]