账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    laravel nginx 下配置 https 访问路径问题
    150
    0

    求助, nginx 开启 https 下配置 xx.conf 路径问题
    一下是 xx.conf 文件中的 location短

    location / {
       index index.html index.htm index.php default.html default.htm default.php forum.php;
       
       #root /home/wwwroot/default/laravel/public;
    
       try_files $uri $uri/ /index.php?$query_string;
       if (!-e $request_filename) {
            rewrite  ^(.*)$  /index.php?s=$1  last;
            break;
       }
    
    }
    问题: root /home/wwwroot/default/laravel/public这一段被放开,会出现404的报错,访问不到 laravel/public里的index.php 但是可以访问到.html的文件

    但是如果 root /home/wwwroot/default/laravel/public这一段被注释, nginx会自动访问到nginx/html目录。访问正常, index.php index.html均可访问

    请问如何才能正常访问到 /home/wwwroot/default/laravel/public 里的php文件

    1
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 仅限观赏 普通会员 1楼

      在 Laravel 的 Nginx 中配置 HTTPS 访问路径问题,你需要首先创建一个新的 SSL 证书,并将其添加到 Nginx 的 SSL 证书文件中。然后,你需要在 Nginx 的配置文件中启用 SSL 证书,并指定域名。

      以下是一个基本的 Nginx 配置示例,用于配置 HTTPS 访问路径:

      ```bash server { listen 443 ssl; server_name example.com;

      ssl_certificate /path/to/your/certificate.pem;
      ssl_certificate_key /path/to/your/private/key.pem;
      
      location / {
          proxy_pass http://localhost:80;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
      

      } ```

      在这个示例中,我们首先监听 443 端口(默认为 HTTPS),然后使用 ssl_certificatessl_certificate_key 来加载 SSL 证书。然后,我们使用 location 路由来指定哪些路径应该使用 HTTPS,并使用 proxy_pass 将请求转发到 http://localhost:80。在 proxy_set_header 中,我们指定了请求的 Host、X-Real-IP 和 X-Forwarded-For 标签,这些标签可以帮助你跟踪请求的源。

      请注意,你需要将 /path/to/your/certificate.pem/path/to/your/private/key.pem 替换为你的 SSL 证书文件的实际路径。此外,你可能需要在你的服务器上安装和配置 SSL 证书,以便 Nginx 能够正确地使用 SSL。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部