dou7466 2019-06-20 11:34 采纳率: 0%
浏览 165
已采纳

如何在Symfony 4本地Web服务器上启用HTTPS

I'm working on Symfony 4 project locally using symfony local web server. How to enable HTTPS locally?

  1. In docs https://symfony.com/doc/current/setup/symfony_server.html#enabling-tls said to use "symfony server:ca:install" command, but I get a error message:

There are no commands defined in the "server:ca" namespace. Did you mean one of these?

doctrine:cache

server

  1. Then I found https://symfony.com/doc/current/security/force_https.html and tried to add

    - { path: ^/, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
    

and clear cache after all. But now it redirected from http://127.0.0.1:8000 to https://127.0.0.1/ with no access to the site

So what is the correct way to configure https?

The main reason to enable https is I want to configure sign in with Facebook, but Facebook demands https connection. So I cannot test it. Or, if you know the way to test sign in with Facebook without https - it would be the best decision!)

Thank you in advance and have a good day who read it!)

  • 写回答

1条回答 默认 最新

  • dt3358 2019-06-20 11:44
    关注

    You probably do not run symfony command correctly, or maybe you have some weird symbolic links. Here is a sample output for my system:

    $ symfony server:ca:install
    
     [OK] The local Certificate Authority is installed and trusted                                                          
    
    

    And what you quote as output looks more like bin/console response.

    FYI, symfony console command can be downloaded here: http://symfony.com/download

    And re your 2nd point, that configuration is valid but it does not enable HTTPS, it only ensures that certain URLs have protocol requirements.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?