【发布时间】:2014-08-01 00:15:08
【问题描述】:
如何在两台服务器之间共享通用配置。我的应用程序同时支持 http 和 https(对于几页),我目前正在使用 fastcgi_param 来保存数据库名称和密码等敏感信息。如何共享两个服务器(80、443)的位置和 fastcgi_param。
服务器 { 听 80; server_name example.com; } 服务器 { 听 443 ssl; server_name example.com; 根 /home/forge/example.com/public; # 伪造 SSL(请勿删除!) 开启ssl; ssl_certificate /etc/nginx/ssl/example.com/304/server.crt; ssl_certificate_key /etc/nginx/ssl/example.com/304/server.key; 索引 index.html index.htm index.php; 字符集 utf-8; 地点 / { try_files $uri $uri/ /index.php?$query_string; } 位置 = /favicon.ico { access_log off; log_not_found 关闭; } 位置 = /robots.txt { access_log off; log_not_found 关闭; } access_log 关闭; error_log /var/log/nginx/example.com-error.log 错误; error_page 404 /index.php; 位置 ~ \.php$ { fastcgi_param ENV“生产”; fastcgi_param DB_HOST "127.0.0.1"; fastcgi_param DB_PASSWORD "123456"; fastcgi_param DB_USERNAME "用户"; fastcgi_param DB_NAME "例子"; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; 包括 fastcgi_params; } 位置 ~ /\.ht { 全部否认; } }我想分享的配置:
索引 index.html index.htm index.php; 字符集 utf-8; 地点 / { try_files $uri $uri/ /index.php?$query_string; } 位置 = /favicon.ico { access_log off; log_not_found 关闭; } 位置 = /robots.txt { access_log off; log_not_found 关闭; } access_log 关闭; error_log /var/log/nginx/example.com-error.log 错误; error_page 404 /index.php; 位置 ~ \.php$ { fastcgi_param ENV“生产”; fastcgi_param DB_HOST "127.0.0.1"; fastcgi_param DB_PASSWORD "123456"; fastcgi_param DB_USERNAME "用户"; fastcgi_param DB_NAME "例子"; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; 包括 fastcgi_params; } 位置 ~ /\.ht { 全部否认; }【问题讨论】:
-
nginx.org/en/docs/http/… 我猜你需要这个
-
你需要include服务器块中的文件。