Skip to content

Instantly share code, notes, and snippets.

@mdmunir
Created March 18, 2020 09:57
Show Gist options
  • Select an option

  • Save mdmunir/7ba57bab1984d2eff1a49780f50d6e29 to your computer and use it in GitHub Desktop.

Select an option

Save mdmunir/7ba57bab1984d2eff1a49780f50d6e29 to your computer and use it in GitHub Desktop.
Apache + socket.io
<VirtualHost *:80>
ServerName dee-basic.test
Redirect permanent "/" "https://dee-basic.test/"
</VirtualHost>
<VirtualHost *:443>
ServerName dee-basic.test
DocumentRoot /var/www/dee-basic/web
SSLEngine on
SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
# Jangan lupa enable proxy_wstunnel
# sudo a2enmod proxy_wstunnel
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/socket.io [NC]
RewriteCond %{QUERY_STRING} transport=websocket [NC]
RewriteRule /(.*) ws://localhost:3001/$1 [P,L]
ProxyRequests on
ProxyPassMatch ^/socket http://localhost:3001
ProxyPassReverse ^/socket http://localhost:3001
<Directory /var/www/dee-basic/web/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
IncludeOptional php73-fcgi.conf
</VirtualHost>
# Redirect to local php-fpm if mod_php is not available
<IfModule !mod_php7.c>
<IfModule proxy_fcgi_module>
# Enable http authorization headers
<IfModule setenvif_module>
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
</IfModule>
<FilesMatch ".+\.ph(ar|p|tml)$">
SetHandler "proxy:unix:/run/php/php7.3-fpm.sock|fcgi://localhost"
</FilesMatch>
<FilesMatch ".+\.phps$">
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(ar|p|ps|tml)$">
Require all denied
</FilesMatch>
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment