如何在两台服务器之间共享通用配置.我的应用程序支持http和https(少数页面),我目前正在使用fastcgi_param来保存敏感信息,如数据库名称和密码.我如何共享服务器的位置和fastcgi_param(80,443).
server {
listen 80;
server_name example.com;
}
server {
listen 443 ssl;
server_name example.com;
root /home/forge/example.com/public;
# FORGE SSL (DO NOT REMOVE!)
ssl on;
ssl_certificate /etc/nginx/ssl/example.com/304/server.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/304/server.key;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/example.com-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_param ENV "production";
fastcgi_param DB_HOST "127.0.0.1";
fastcgi_param … 我已完成我之前的研究,但似乎无法找到如何正确配置nginx以接受子域.
我目前已为mydomain.com正确配置,但不是analytix.mydomain.com:
server {
listen 80;
server_name *.mydomain.com;
access_log /home/ubuntu/virtualenv/mydomain/error/access.log;
error_log /home/ubuntu/virtualenv/mydomain/error/error.log warn;
connection_pool_size 2048;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
root /home/ubuntu/virtualenv/mydomain/homelaunch/;
location /static/ {
alias /home/ubuntu/virtualenv/mydomain/homelaunch/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
Run Code Online (Sandbox Code Playgroud)
该server_name声明被接受<anythinghere>.mydomain.com,这是很好.
如果我访问analytix.mydomain.com它,它会抛出一个Http 500默认值,这很好,因为它从现有的应用程序抛出它mydomain.com
该域名已经传播到我正在尝试访问它的服务器上.
如何指定路径中的文件夹以容纳内容analytix.mydomain.com?我想我会要求更改nginx conf中的属性(如上所示)