Laravel Forge Nginx将所有子域重定向到https://example.com

时间:2017-09-11 07:31:38

标签: laravel ssl nginx dns laravel-forge

因此,我使用Laravel Forge的内置功能来生成和集成LetsEncrypt证书。但我在让我的子域工作方面遇到了问题。

每当我尝试访问www.example.com或https://www.example.com时,它都会将我重定向到https://example.com。当我尝试添加更多子域名时会发生同样的情况,例如foo.example.com重定向到https://example.com

我的域名是使用Namecheap托管的,并将其设置为:

enter image description here

这是由Forge生成的我的Nginx配置文件:

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/before/*;

# FORGE CONFIG (DOT NOT REMOVE!)
include upstreams/example.com;

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name example.com;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/example.com/244866/server.crt;
    ssl_certificate_key /etc/nginx/ssl/example.com/244866/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    charset utf-8;

    access_log off;
    error_log  /var/log/nginx/example.com-error.log error;

    # FORGE CONFIG (DOT NOT REMOVE!)
    include forge-conf/example.com/server/*;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://386082_app/;
        proxy_redirect off;

        # Handle Web Socket Connections
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

# FORGE CONFIG (DOT NOT REMOVE!)
include forge-conf/example.com/after/*;

这是我第一次使用Nginx服务器,因此我不确定如何更改它。我已尝试在Namecheap DNS设置中使用我的设置,并确保我的SSL是使用所有子域生成的,但我不知道问题是在nginx配置中的任何地方。搜索周围并没有给我一个可靠的解决方案,因为我不想远离Forge的默认配置,但仍然按照我的方式管理这项工作。

任何和所有帮助都将受到高度赞赏!

谢谢

0 个答案:

没有答案
相关问题