dify-1:nginx基线
dify的nginx容器启动时会将docker/nginx/nginx.conf.template复制为nginx.conf、将docker/nginx/conf.d/default.conf.template复制为default.conf后再加载它们。因此加固基线需要修改这两个文件,红色粗体为新增:
nginx.conf.template
# Please do not directly edit this file. Instead, modify the .env variables related to NGINX configuration. user nginx; worker_processes ${NGINX_WORKER_PROCESSES}; error_log /var/log/nginx/error.log notice; 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 ${NGINX_KEEPALIVE_TIMEOUT}; #gzip on; client_max_body_size ${NGINX_CLIENT_MAX_BODY_SIZE}; # nginx baseline limit_conn_zone $binary_remote_addr zone=one:10m; # nginx baseline include /etc/nginx/conf.d/*.conf; }
default.conf.template
# Please do not directly edit this file. Instead, modify the .env variables related to NGINX configuration. server { listen ${NGINX_PORT}; server_name ${NGINX_SERVER_NAME}; # nginx baseline server_tokens off; limit_conn one 10; limit_rate 1500k; error_page 400 401 402 403 404 405 408 410 412 413 414 415 500 501 502 503 504 506 /404.html; client_body_timeout 300s; client_header_timeout 30s; send_timeout 30s; # nginx baseline location /console/api { proxy_pass http://api:5001; include proxy.conf; } location /api { proxy_pass http://api:5001; include proxy.conf; } location /v1 { proxy_pass http://api:5001; include proxy.conf; } location /files { proxy_pass http://api:5001; include proxy.conf; } location /explore { proxy_pass http://web:3000; include proxy.conf; } location /e/ { proxy_pass http://plugin_daemon:5002; proxy_set_header Dify-Hook-Url $scheme://$host$request_uri; include proxy.conf; } location / { proxy_pass http://web:3000; include proxy.conf; } # placeholder for acme challenge location ${ACME_CHALLENGE_LOCATION} # placeholder for https config defined in https.conf.template ${HTTPS_CONFIG} }