我的 CentOS 7 中有这样的配置:
$ cat /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name 8.8.8.8;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我正在尝试进行虚拟主机配置,例如:
if visitor (www.domain1.com) then /usr/share/nginx/html/domain1
if visitor (www.domain2.com) then /usr/share/nginx/html/domain2
如何从请求进入的主机签入我的 default.conf?这样我就可以将它们路由到正确的目录?