|
1 |
| -<VirtualHost *:80> |
2 |
| - ServerName coder.example.com |
3 |
| - ServerAlias *.coder.example.com |
4 |
| - <Location "/"> |
5 |
| - Redirect permanent "https://%{HTTP_HOST}%{REQUEST_URI}" |
6 |
| - </Location> |
7 |
| -</VirtualHost> |
| 1 | + # Redirect HTTP to HTTPS |
| 2 | + <VirtualHost *:80> |
| 3 | + ServerName coder.example.com |
| 4 | + ServerAlias *.coder.example.com |
| 5 | + Redirect permanent / https://coder.example.com/ |
| 6 | + </VirtualHost> |
8 | 7 |
|
9 |
| -<VirtualHost *:443> |
10 |
| - ServerName coder.example.com |
11 |
| - ServerAlias *.coder.example.com |
12 |
| - ErrorLog ${APACHE_LOG_DIR}/error.log |
13 |
| - CustomLog ${APACHE_LOG_DIR}/access.log combined |
| 8 | + <VirtualHost *:443> |
| 9 | + ServerName coder.example.com |
| 10 | + ServerAlias *.coder.example.com |
| 11 | + ErrorLog ${APACHE_LOG_DIR}/error.log |
| 12 | + CustomLog ${APACHE_LOG_DIR}/access.log combined |
14 | 13 |
|
15 |
| - ProxyPass / http://127.0.0.1:3000/ |
16 |
| - ProxyPassReverse / http://127.0.0.1:3000/ |
17 |
| - ProxyRequests Off |
18 |
| - ProxyPreserveHost On |
| 14 | + ProxyPass / http://127.0.0.1:3000/ upgrade=any # required for websockets |
| 15 | + ProxyPassReverse / http://127.0.0.1:3000/ |
| 16 | + ProxyRequests Off |
| 17 | + ProxyPreserveHost On |
19 | 18 |
|
20 |
| - RewriteEngine On |
21 |
| - RewriteCond %{HTTP:Connection} Upgrade [NC] |
22 |
| - RewriteCond %{HTTP:Upgrade} websocket [NC] |
23 |
| - RewriteRule /(.*) ws://127.0.0.1:3000/$1 [P,L] |
24 |
| - |
25 |
| - SSLCertificateFile /etc/letsencrypt/live/coder.example.com/fullchain.pem |
26 |
| - SSLCertificateKeyFile /etc/letsencrypt/live/coder.example.com/privkey.pem |
27 |
| -</VirtualHost> |
| 19 | + RewriteEngine On |
| 20 | + # Websockets are required for workspace connectivity |
| 21 | + RewriteCond %{HTTP:Connection} Upgrade [NC] |
| 22 | + RewriteCond %{HTTP:Upgrade} websocket [NC] |
| 23 | + RewriteRule /(.*) ws://127.0.0.1:3000/$1 [P,L] |
28 | 24 |
|
| 25 | + SSLCertificateFile /etc/letsencrypt/live/coder.example.com/fullchain.pem |
| 26 | + SSLCertificateKeyFile /etc/letsencrypt/live/coder.example.com/privkey.pem |
| 27 | + </VirtualHost> |
| 28 | + |
0 commit comments