我目前已经在example.com上设置了NGINX域名,它可以正常工作。我想设置一个子域test.example.com,但在遵循多个不同的指令后,我要么继续获取404,要么被重定向到主域。
我的服务器配置和文件结构如下所示:
/usr/local/nginx
├── conf
│ ├── fastcgi_params
│ ├── includes
│ ├── nginx.conf
│ ├── nginx.conf.save
│ ├── sites
│ │ ├── example.com.conf
│ │ ├── test.example.com.conf
│ ├── uwsgi_params
│ └── win-utf
├── html
├── logs
└── snippets
├── ssl-example.com.conf
└── ssl-params.conf
/var/www
├── example.com
│ └── ...
└── test.example.com
└── index.html我已经更新了DNS记录以便"*.example.com“指向相同的IP
默认域example.com.conf文件如下所示:
server {
listen 80;
server_name exmaple.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location ~ /.well-known {
root /var/www/lets-encrypt/example.com;
access_log off;
expires max;
break;
}
include /usr/local/nginx/conf/includes/m2-php71.conf;
}和子域test.example.com.conf文件:
server {
listen 80;
server_name test.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name test.example.com;
ssl_certificate /etc/letsencrypt/live/test.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.exampe.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location ~ /.well-known {
root /var/www/lets-encrypt/test.example.com;
access_log off;
expires max;
break;
}
include /usr/local/nginx/conf/includes/m2-php71.conf;
}当我删除侦听443部分时,它会重定向到主域。
我希望从var/www/test.subdomain.com获得子域test.example.com的请求,但似乎无法通过404错误
发布于 2019-04-17 17:46:24
您需要执行以下操作:
对于这两个配置,从服务器中的两个configurations.
alias之一部分中删除www.example.com。发布于 2019-04-27 09:35:36
问题出在php.conf文件上。我应该意识到这一点,因为我能够加载index.html文件,而不是.php文件。在包含了正确的php.conf文件之后,一切都开始工作了。
https://stackoverflow.com/questions/55698400
复制相似问题