Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save VuongNQ/390632142273101ffa93a44dac6ca970 to your computer and use it in GitHub Desktop.
Save VuongNQ/390632142273101ffa93a44dac6ca970 to your computer and use it in GitHub Desktop.
Virtual host proxy Apache with SSL (Laragon config)

Requiment:

Step

1: open app and choose Menu -> Apache -> SSl and enable

2: on Menu, select Quick app and choose an app Blank

3: enter name app you want to create(no space) => after tool create, your domain like

<name>.test

4: make sure you had create app and enable SSl, choose Menu -> Apache -> httpd.conf

5: make sure list mod for proxy below is enable (just remove # at begin)

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so
LoadModule ssl_module modules/mod_ssl.so

after check all, save and comeback app

6: choose Menu -> Apache -> sites-enabled and select app blank had created from step3, open file conf to edit

7: at section <VirtualHost *:80>, add code below

ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://localhost:3000/$1" [P,L]
ProxyRequests Off

Note: localhost:3000 is host you want config proxy

8: at section <VirtualHost *:443> add code before key SSl store

SSLProxyCheckPeerName off
SSLProxyVerify none
SSLEngine on
SSLProxyEngine on

and add code proxy like above

Example config

define ROOT "C:/laragon/www/app-test"
define SITE "apptest.local"

<VirtualHost *:80> 
    DocumentRoot "${ROOT}"
    ServerName ${SITE}
    ServerAlias *.${SITE}
    <Directory "${ROOT}">
        AllowOverride All
        Require all granted
    </Directory>
	
	ProxyPass / http://localhost:3000/
	ProxyPassReverse / http://localhost:3000/
	RewriteEngine on
	RewriteCond %{HTTP:Upgrade} websocket [NC]
	RewriteCond %{HTTP:Connection} upgrade [NC]
	RewriteRule ^/?(.*) "ws://localhost:3000/$1" [P,L]
	ProxyRequests Off
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot "${ROOT}"
    ServerName ${SITE}
    ServerAlias *.${SITE}
    <Directory "${ROOT}">
        AllowOverride All
        Require all granted
    </Directory>


	SSLProxyCheckPeerName off
	SSLProxyVerify none
	SSLEngine on
	SSLProxyEngine on
    SSLCertificateFile      C:/laragon/etc/ssl/laragon.crt
    SSLCertificateKeyFile   C:/laragon/etc/ssl/laragon.key
	
	
	ProxyPass / http://localhost:3000/
	ProxyPassReverse / http://localhost:3000/
	RewriteEngine on
	RewriteCond %{HTTP:Upgrade} websocket [NC]
	RewriteCond %{HTTP:Connection} upgrade [NC]
	RewriteRule ^/?(.*) "ws://localhost:3000/$1" [P,L]
	ProxyRequests Off
 
</VirtualHost>

  1. Save and close file config, reload or stop and start app

  2. on Menu, selece www and open app with https had config

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