[英]Nginx Server Configuration: Hostname not resolving on Subdomain
thank you in advance for your support.预先感谢您对我们的支持。
I set up an Ubuntu Server with Nginx as a Digitalocean Droplet and am using the server provisioning tool Laravel Forge , which works fine.我设置了一个 Ubuntu 服务器,其中 Nginx 作为 Digitalocean Droplet,并且正在使用服务器配置工具Laravel Forge ,它工作正常。 I successfully installed the PHP Framework Laravel and deployed the code on the server.
我成功安装了 PHP 框架 Laravel 并将代码部署在服务器上。 I ssh into the server and checked the files in the supposed directory.
我 ssh 进入服务器并检查了假定目录中的文件。 The code is successfully deployed.
代码部署成功。
Next I own a domain, and created an A record for the following subdomain: app.mywebsite.de , that points to that server.接下来,我拥有一个域,并为以下子域创建了一条 A 记录: app.mywebsite.de ,它指向该服务器。 I followed the digitalocean instructions and I waited the required time.
我按照digitalocean 的指示等待了所需的时间。 Using a DNS Lookup tool, I confirmed that the subdomain actually points to the server.
使用 DNS 查找工具,我确认子域实际上指向服务器。
Screenshot of DNS Lookup DNS 查找的屏幕截图
Yet, when I use the subdomain in my browser, the browser doesn't connect to the server.然而,当我在浏览器中使用子域时,浏览器并没有连接到服务器。 I get the following error message in the browser:
我在浏览器中收到以下错误消息:
Screenshot of Browser when connecting to server浏览器连接服务器时的截图
It seems like the subdomain is correctly pointed to the server, but the server isn't rightly configured.似乎子域正确指向服务器,但服务器配置不正确。 I tried to check the nginx configuration and under sites-avaialble I have the following configuration for the subdomain:
我尝试检查 nginx 配置,在站点可用下,我对子域有以下配置:
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/app.mywebsite.de/before/*;
server {
listen 80;
listen [::]:80;
server_name app.mywebsite.de;
server_tokens off;
root /home/forge/app.mywebsite.de/public;
# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS_AES_256_GCM_SHA384:TLS-AES-256-GCM-SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS-CHACHA20-POLY1305-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/app.mywebsite.de/server/*;
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/app.mywebsite.de-error.log error;
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/app.mywebsite.de/after/*;
In forge-conf/app.website.de/before/*;在forge-conf/app.website.de/before/*; is only one file redirect.conf with the following code:
只有一个文件redirect.conf ,代码如下:
server {
listen 80;
listen [::]:80;
server_name www.app.website.de;
if ($http_x_forwarded_proto = 'https') {
return 301 https://app.website.de$request_uri;
}
return 301 $scheme://app.website.de$request_uri;
}
There are no other sites on the server.服务器上没有其他站点。 So there is only the 000-catch-all file in the sites available directory of the nginx configuration folder.
因此,nginx 配置文件夹的站点可用目录中只有000-catch-all文件。
Unfortunately I reached my limit of understanding here and I would love if somebody could point me into the right direction to find out, which part of nginx is not configured corectly.不幸的是,我在这里达到了我的理解极限,如果有人能指出我正确的方向来找出答案,我会很高兴,nginx 的哪一部分没有正确配置。
PS Some additional info: Yes I restarted Nginx and the whole server multiple times. PS 一些附加信息:是的,我多次重新启动 Nginx 和整个服务器。
Turns out, everything was configured correctly.事实证明,一切都配置正确。 I didn't change anything, except that I added some additional sites on the nginx server.
除了在 nginx 服务器上添加了一些额外的站点之外,我没有进行任何更改。 Forge probably updated the server blocks, which resolved the problem.
Forge 可能更新了服务器块,从而解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.