Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Caffe1neAdd1ct/cf9f600bfe77d5a6edf4c4c495740fcb to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/cf9f600bfe77d5a6edf4c4c495740fcb to your computer and use it in GitHub Desktop.
Apache Reverse Proxy to PHP InBuilt Webserver with SSL
<VirtualHost *:443>
ServerName app.host.local
ServerAdmin root@localhost
DocumentRoot "/srv/http/"
<Directory "/srv/http/">
Options -Indexes -FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
ProxyPass "/" "http://localhost:8000/"
ProxyPassReverse "/" "http://localhost:8000"
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}
# Enable SSL
SSLEngine On
SSLCertificateFile /etc/ssl/certs/tls/app.host.local.pem
SSLCertificateKeyFile /etc/ssl/certs/tls/app.host.local.key
SSLInsecureRenegotiation Off
SSLCompression Off
ErrorLog "/var/log/httpd/app.host.local/error.log"
CustomLog "/var/log/httpd/app.host.local/access.log" combined
</VirtualHost>
@Caffe1neAdd1ct
Copy link
Author

Forward headers allow laravel apps to work correctly when generating URLs, redirects and routes when running behind an SSL proxy with the local env running in plain http inbuilt websever

Using mkcert to provide local valid ssl certs copied into /etc/ssl/certs/tls/

Permissions

chown root:root
chmod 400 *.key
chmod 640 *.pem

mkdir /var/log/httpd/app.host.local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment