服务器将地址栏中的域名更改为 IP

服务器将地址栏中的域名更改为 IP

我不是服务器专家,所以寻求一些帮助。我在 digital ocean droplet 上托管了一个 laravel 项目,并将在 godaddy 注册的子域名指向该 droplet。尝试访问网站时,地址栏正在更新以显示服务器 IP,而不是相关域。

该域名分为两部分,基本域名指向 wordpress 服务器,myaccount 子域名指向 digital ocean droplet。

已应用的 DNS 记录:

CNAME www -> @

@ -> XX.XXX.XX.XXX

子域名 -> 184.168.131.241

(设置转发规则时 godaddy 自动设置为指向 68.183.26.235 的服务器,我猜测是某个内部转发地址)。

服务器配置:

NGINX配置文件

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        client_max_body_size 120M;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs

可用站点:alphamark-client (符号链接到 sites-enabled)

server {
    server_name subdomain.example.com;
    root /var/www/alphamark-client/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    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; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/subdomain.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/subdomain.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = subdomain.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name subdomain.example.com;
    return 404; # managed by Certbot


}

Laravel 应用环境:

APP_NAME=Alphamark客户端

APP_ENV=生产

APP_DEBUG=false

APP_URL=https://subdomain.example.com

尝试访问子域时,可以访问服务器。但是,地址栏会更新以反映服务器 IP。这也会破坏 SSL 证书,因为它已注册到子域。任何帮助确定我的设置的哪个部分导致此行为的帮助都将不胜感激。

相关内容