HTTPS not recognized in Symfony API REST

I have a Symfony API REST, enabled in my apache production server, which uses HTTPS and certified A+ security by Querys SSL test.

Via a POST route https://hooks.loginnove.fr/hooks, the API returns a url property, generated with $request->generateUrl method of Symfony Request.
The problem is that the API always generates a http:// url since Symfony does not recognize that the server is using HTTPS (tested with $request->getScheme & $request->getPort).

I have created a new production environnement on my own local, with the same virtual host config: it works !

But I still don’t understand why the production server does not work… Here is my config :

<VirtualHost *:80>
    ServerName api.hooks
    
    Redirect 308 / https://prod.api.hooks/
</VirtualHost>
<VirtualHost *:443>
    ServerName prod.api.hooks
    
    SSLEngine on
    SSLCertificateKeyFile "${SRVROOT}/conf/key/private.key"
    SSLCertificateFile "${SRVROOT}/conf/key/certificate.crt"
    
    Header set Access-Control-Allow-Origin "*"
    Header always set Content-Security-Policy "default-src 'none'!"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
    Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains;"
    Header always set X-Content-Type-Options "nosniff"
    
    DocumentRoot C:/wamp64/www/production/hooks/public
    <Directory "C:/wamp64/www/production/hooks/public">
        AllowOverride None
        Require all granted
        
        FallbackResource /index.php
    </Directory>
        
    <Directory "C:/wamp64/www/production/hooks/public/bundles">
        FallbackResource disabled
    </Directory>
</VirtualHost>

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *