How to enable HTTPS on Symfony 4 local web server

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!)

Upvotes: 5

Views: 12319

Answers (1)

alx
alx

Reputation: 2367

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.

Upvotes: 9

Related Questions