Ryan H
Ryan H

Reputation: 2953

Laravel Octane with Swoole HTTPS configuration apache vhost proxy error

I'm trying to setup SSL for my Laravel 11 website in which is running through Laravel Octane. I'm using swoole, have generated a let's encrypt ssl certificate and set swoole.ssl to true in my octane config file. When I start my octane server and visit the http variant for my domain i get a 502 proxy error, if i try to visit the https variant i get just a general browser error. What am I missing in my apache vhost to get my website served through https:

<VirtualHost *:80>
    ProxyPreserveHost On

    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/

    ServerName my-site.domain.com
    ServerAdmin admin@localhost
    DocumentRoot /var/www/icicle/current/public;

    <Directory /var/www/icicle/current/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:443>
    ServerName my-site.domain.com
    ServerAdmin admin@localhost
    DocumentRoot /var/www/icicle/current/public

    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/my-site.domain.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/my-site.domain.com/privkey.pem

    ProxyPreserveHost On

    ProxyPass / http://127.0.0.1:8000/
    ProxyPassReverse / http://127.0.0.1:8000/

    <Directory /var/www/icicle/current/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

I've added the following to my octane config file:

'swoole' => [
    'ssl' => true,
    'options' => [
        'ssl_cert_file' => '/etc/letsencrypt/live/my-site.domain.com/cert.pem',
        'ssl_key_file' => '/etc/letsencrypt/live/my-site.domain.com/privkey.pem',
    ]
],

Upvotes: 0

Views: 507

Answers (2)

Alli Baba
Alli Baba

Reputation: 36

If you are using Apache as a reverse proxy for Swoole then you don't need to enable SSL in Swoole. Apache will handle the secure connection with the browser and swoole can just run its http server without TLS on port 8000.

You can set 'ssl' => false in the octane config

Upvotes: 0

Luffy
Luffy

Reputation: 141

You just need to configure the web server correctly without setting the certificate information in the swoole.

Upvotes: 0

Related Questions