Reverse proxy forwarding with Apache [The missing guide] #2718
Unanswered
Dungeonseeker
asked this question in
General
Replies: 1 comment
-
Thanks for documenting this @Dungeonseeker ! 🎉 If you'd like, you can open a PR and add this to the docs! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In case anyone still cannot get this working with Apache heres how I managed it.
Code Server Config
sudo systemctl stop code-server@root (change root to required user)
sudo nano ~/.config/code-server/config.yaml
sudo systemctl start code-server@root (change root to required user)
Apache2 Config
cd /etc/apache2/sites-available/
sudo nano code.conf
<VirtualHost *:80>
ServerName code.domain.name.here
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://192.168.1.45:420/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://192.168.1.45:420/$1 [P,L]
ProxyRequests off
ProxyPass / http://192.168.1.45:420/ nocanon
ProxyPassReverse / http//192.168.1.45:420/
</VirtualHost>
*Note: If you didn't specify a custom port then uses code-servers default (8080)
*Note2: edit all of these options to your required settings for the rest of this guide, I won't point it out again
sudo a2ensite code
sudo systemctl restart apache2
Now you should be able to access code from your specified sub domain.
SSL Config
Before proceeding make sure the above steps are all finished and you can access code server
certbot --apache
cd /etc/apache2/sites-enabled/
sudo nano code.conf
<VirtualHost *:80>
ServerName code.your.domain.here
ServerAdmin webmaster@localhost
Redirect permanent / https://code.your.domain.here
</VirtualHost>
sudo nano code-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName code.your.domain.here
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://192.168.1.45:420/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://192.168.1.45:420/$1 [P,L]
ProxyRequests off
ProxyPass / http://192.168.1.45:420/ nocanon
ProxyPassReverse / http//192.168.1.45:420/
SSLCertificateFile /etc/letsencrypt/live/your.domain.here/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/your.domain.here/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
sudo systemctl restart apache2
Now code server should be ready on
https://code.yourdomain
andhttp://code.yourdomain
will forward users to https.Hope this helps (maybe add this to the install guide?)
Beta Was this translation helpful? Give feedback.
All reactions