Skip to content

Instantly share code, notes, and snippets.

@iacchus
Created July 22, 2022 06:28
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 iacchus/01c6f4998809ef1bd3225d8217dce10f to your computer and use it in GitHub Desktop.
Save iacchus/01c6f4998809ef1bd3225d8217dce10f to your computer and use it in GitHub Desktop.
Vite with Apache Reverse Proxy Inside Docker Fully functional
# you don't need to change anything in the default `vite.config.js`, only proxy / for the web and for the websockets.
<VirtualHost *:80>
ServerName my.site.org
ServerAdmin webmaster@localhost
RewriteEngine on
RewriteCond %{SERVER_NAME} =my.site.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName my.site.org
ServerAdmin webmaster@localhost
<Location />
# Require all granted #uncomment this
# Require ip xxx.xxx.xxx.xxx
</Location>
# vue-vite is the my docker-compose host, use your local hostname or ip address
ProxyPass / http://vue-vite:5173/
ProxyPassReverse / http://vue-vite:5173/
<Location />
ProxyPass ws://vue-vite:5173/
ProxyPassReverse ws://vue-vite:5173/
</Location>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /etc/letsencrypt/live/my.site.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my.site.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment