隔离 Laravel url 使其成为 http 而其余为 https

Posted

技术标签:

【中文标题】隔离 Laravel url 使其成为 http 而其余为 https【英文标题】:Isolate Laravel url to make it http while rest is https 【发布时间】:2018-07-05 21:18:54 【问题描述】:

简介:

我想创建一个 http(非安全)公共 url 来处理 Redsys(支付网关)回调。 为什么是http?因为我有 Cloudflare,他们不喜欢他们的共享 证书 -> 握手错误 为什么不将我自己的证书(单一 IP)上传到 Cloudflare?因为我要支付月费,而且到目前为止是一个小项目。 解决方法?创建一个 http url 并在那里处理回调

情况:

我正在使用 Laravel,并创建了一条到我的控制器“/tpv”的路由 我已经准备好所有的 nginx 配置,正在监听 80

问题:

我的重定向太多了,因为 location /tpv 调用 Laravel (index.php/tpv) 受 location / redirect to https

问题:

有什么创意可以解决这个问题吗?

想法:

在名为 tpv 的文件夹中创建一个外部 php 脚本,并从那里调用 Laravel 控制器,但不知道如何执行此操作或是否可行。 删除 Ngnix conf 并按照帖子 Laravel 5 - redirect to HTTPS 直接使用 Laravel 管理重定向

在更改为 Nginx 之前,我正在使用 Rewrites,这可能是解决方案:

RewriteCond %SERVER_PORT 80 RewriteCond %THE_REQUEST !/tpv [NC]

Ngnix conf 供参考:

server 
   listen 80;
   listen [::]:80;
   server_name .example.com;
   root /home/forge/example.com/public;
   location /tpv 
       return 301 http://example.com/index.php/tpv;
   
   location /index.php/tpv 
       return 301 http://example.com/index.php/tpv;
   
   location /   # the default location redirects to https
        return 301 https://$host$request_uri;
   

【问题讨论】:

您使用的是弹性 SSL 还是完整 SSL?如果您只使用灵活,您可以在 Full 上使用(免费)自签名证书,这有帮助吗?或者您是否考虑过使用 Cloudflare 页面规则来禁用该特定页面的 SSL? 或者,当然,考虑到支付网关真的,真的应该是安全的,为什么不试试letsencrypt.org? @LeonardChalis 问题是提供商不喜欢共享 SSL,我有完整的(严格)所以提供商要找到的第一个证书是 Cloudflare,然后从 Cloudflare 到我的服务器我我已经在使用 Lets Encrypt,但提供商找不到。 【参考方案1】:

在你有好的想法之前,在 conf 中试试这个简单的魔法代码;)

server 
   listen 80;
   listen [::]:80;
   server_name .example.com;
   root /home/forge/example.com/public;

   location ^~  /tpv* 
       return 301 https://$host$request_uri;
   

   try_files $uri $uri/ /index.php?$query_string;

   location ~ \.php$ 
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    

【讨论】:

只是一个小改动,让它更好地工作location ^~ /tpv try_files $uri $uri/ /index.php?$query_string; location / return 301 https://$host$request_uri;

以上是关于隔离 Laravel url 使其成为 http 而其余为 https的主要内容,如果未能解决你的问题,请参考以下文章

将 Typescript 与 Laravel 和 Vue.js 一起使用,导入不使其成为 Vue 组件?

Laravel迁移变为使列可以为空

xml Android - Drawable paiting line of dots(删除旋转标记使其成为水平)。来源= http://stackoverflow.com/a/20605455/

xml Android - Drawable paiting line of dots(删除旋转标记使其成为水平)。来源= http://stackoverflow.com/a/20605455/

xml Android - Drawable paiting line of dots(删除旋转标记使其成为水平)。来源= http://stackoverflow.com/a/20605455/

xml Android - Drawable paiting line of dots(删除旋转标记使其成为水平)。来源= http://stackoverflow.com/a/20605455/