在Laravel中更改路径到子域

时间:2016-08-27 16:18:45

标签: laravel nginx laravel-5.2 subdomain cloudflare

我的Laravel应用程序中有一个网址:https://domain.com/admin,现在我想将其移至https://admin.domain.com。我使用Cloudflare作为名称服务器,nginx。当我访问https://admin.domain.com时,它会显示红色https警告,当我访问http://admin.domain.com时,它会显示nginx测试页。我怎么能这样做? 我在cloudflare(Cname)中创建了子域名'admin' Nginx配置:

server {
        server_name www.domain.tv;
        rewrite ^(.*) https://domain.tv$1 permanent;
        }
server {
        listen 80;
        server_name *.domain.tv;
        return 301 https://$server_name$request_uri;
}
server {    
    listen 443 ssl http2; # Use this config for Nginx from 1.9.5 version
    listen 80;
    #listen 443 ssl http2; # Use this config for Nginx before 1.9.5 version
    ssl_certificate /etc/nginx/ssl/domain.tv/ssl-bundle.crt;
    ssl_certificate_key /etc/nginx/ssl/domain.tv/domain.tv.key; 
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_prefer_server_ciphers on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!CAMELLIA:!DES-CBC3-SHA;
    #ssl_stapling on;
    #resolver 8.8.4.4 8.8.8.8 valid=300s;
    #resolver_timeout 10s;
    ssl_trusted_certificate /etc/nginx/ssl/domain.tv/ssl-bundle.crt;
    ssl_buffer_size 1400;
    ssl_session_tickets on;
    add_header Strict-Transport-Security max-age=31536000;
        access_log off;
        error_log off;
        # error_log /home/domain.tv/logs/error.log;
        root /home/domain.tv/public_html/MovieWebApp/public;    
    include /etc/nginx/conf/ddos2.conf;
    index index.php index.html index.htm;
    server_name *.domain.tv;

1 个答案:

答案 0 :(得分:0)

您必须为每个子域创建A记录,您必须使用带有cloudflare和nginx的(*)重定向来实现此目的。我认为cloudflare不会免费提供asterix重定向。