Skip to content

Instantly share code, notes, and snippets.

@vvasilev-
Last active August 29, 2015 14:15
Show Gist options
  • Save vvasilev-/159068cd5ede0401a44c to your computer and use it in GitHub Desktop.
Save vvasilev-/159068cd5ede0401a44c to your computer and use it in GitHub Desktop.
Self-Signed SSL with Apache 2.2 & Laravel on Windows

Requirements

Self-signed certificate

  • start Windows Command Prompt as Administrator
  • go to C:\OpenSSL\bin(or the folder where you installed OpenSSL)
  • follow the steps from 1 to 4 - http://www.akadia.com/services/ssh_test_certificate.html
  • copy the server.key & server.crt to <Apache2.2>/conf/ssl
  • open the httpd.conf and add Listen 443
  • enable mod_ssl in httpd.conf
  • at end of httpd.conf add this
<IfModule ssl_module>
	SSLRandomSeed startup builtin
	SSLRandomSeed connect builtin
	SSLSessionCache none
</IfModule>

Setup virtual host

<VirtualHost *:80>
    DocumentRoot "path-to-public-folder"
    ServerName yourapp.example.com
    ServerAlias *.yourapp.example.com
</VirtualHost>
<VirtualHost *:443>
    DocumentRoot "path-to-public-folder"
    ServerName yourapp.example.com
    SSLEngine On
    SSLCertificateFile conf/ssl/server.crt
    SSLCertificateKeyFile conf/ssl/server.key
</VirtualHost>

.htaccess for Laravel 4+

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect to HTTPS...
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Open http://yourapp.example.com and you will be redirected to https://yourapp.example.com

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