【问题标题】:Laravel app wildcard Digitalocean nginxLaravel 应用通配符 Digitalocean nginx
【发布时间】:2014-10-19 00:19:49
【问题描述】:

我在 Digitalocean (nginx) 上设置了一个 Laravel 应用程序。

当我去 site.com 时它工作正常,但当我去 www.site.com 时它不会加载。

我的问题是如何在 Digitalocean 设置 DNS 记录以及如何设置 /etc/nginx/sites-available/default 文件:

  1. www.site.com/path 应该重定向到 site.com/path。
  2. 所有子域都应引用主应用站点。
  3. media.site.com 应参考其他目录。

谢谢!

这是现在的文件:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /var/www/hzofe/public;
    index index.php index.html index.htm;

    server_name localhost;

    location / {
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

【问题讨论】:

    标签: laravel nginx laravel-4 digital-ocean


    【解决方案1】:

    您是否尝试为 DNS 重定向添加 cname 记录?

    此外,如果您使用 https,则可以为别名域制作一份证书,并使用 Lets-encrypt 制作您的常规证书。

    这是一个 nodejs 教程,但它可能会有所帮助......

    https://code.lengstorf.com/deploy-nodejs-ssl-digitalocean/#install-nginx

    【讨论】:

      【解决方案2】:
      server {
          listen 80;
          listen [::]:80 ipv6only=on;
      
          server_name media.site.com;
          ....
      }
      
      
      server {
          listen 80;
          listen [::]:80 ipv6only=on;
      
          server_name *.site.com;
          ....
      }
      

      【讨论】:

      • 谢谢,但它失败了,'duplicate listen options for [::]:80'。
      猜你喜欢
      • 1970-01-01
      • 2017-04-27
      • 2023-03-26
      • 2018-07-27
      • 1970-01-01
      • 1970-01-01
      • 2017-02-07
      • 2020-04-08
      • 2023-03-13
      相关资源
      最近更新 更多