我的 nginx 设置遇到了一些问题。
我正在尝试为另一个系统路径设置一个子域,但由于某种原因,nginx 重定向到一个捕获所有通配符而不是确切的通配符。
配置如下:
server {
listen 8080;
listen [::]:8080;
root /www/example.com/public;
index index.php index.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
server {
listen 8080;
listen [::]:8080;
root /www/example.com/public_static;
index index.html
server_name static.example.com;
location / {
try_files $uri $uri/ =404;
}
}
server {
listen 8080;
listen [::]:8080;
root /www/example.com/public;
server_name *.examlpe.com;
location / {
try_files $uri /nosub.html;
}
}
还有一个反向代理正在运行,其配置如下:
upstream internalservers {
server 127.0.0.1:8080;
}
server {
listen 80;
listen [::]:80;
listen 443;
listen [::]:443;
server_name _;
location / {
proxy_set_header Host $http_host;
proxy_pass http://internalservers;
}
}
server {
listen 8080;
listen [::]:8080;
root /www/default/
server_name _;
location / {
try_files $uri /nodomain.html;
}
}
当我尝试访问特定的子域(静态)时,它会重定向到定义的 catch-all 子域,因此我认为这不是代理设置中的问题。