例如下面这个配置块。我有N个PHP站点,他们除了server_name和root这个配置项不同以外,其他配置项都是一样的,有什么办法可以复用其他相同的配置吗?
另外请问一下,我下面这个配置项是否有安全隐患?如果有的话需要怎么修改呢?
非常感谢!^_^
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name www.xxx.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
一般复用就用
include
语句就行了,暂时没太好的方法……(写完Caddy配置再回来看Nginx的配置,尤其会有种想骂街的感觉。。)