Reverse proxy with Apache httpd
For this you will need Apache httpd server. That is a fairly popular package so your distro will probably have it.
sudo apt install apache2
sudo pacman -S apache
sudo zypper install apache2
In your GoToSocial config turn off letsencrypt. First open the file in your text editor.
If GoToSocial is already running, restart it.
sudo systemctl restart gotosocial.service
Or if you don't have a systemd service just restart it manually.
Set up Apache httpd
First we will set up Apache httpd to serve GoToSocial as unsecured http and then later use certbot to automatically upgrade to https. Please do not try to use it until that's done or you'll be transmitting passwords over clear text.
First we'll write a configuration for Apache httpd and put it in
sudo mkdir /etc/apache2/sites-available/ sudoedit /etc/apache2/sites-available/yourgotosocial.url.conf
The file you're about to create should look a bit like this:
<VirtualHost *:80> ServerName example.com ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ </VirtualHost>
ProxyPreserveHost On is essential: It guarantees that the proxy and the gotosocial speak of the same Server name. If not, gotosocial will build the wrong authentication headers, and all attempts at federation will be rejected with 401.
ProxyPass to the ip and port that you're actually serving GoToSocial on and change
ServerName to your own domain name.
If your domain name is
ServerName gotosocial.example.com; would be the correct value.
If you're running GoToSocial on another machine with the local ip of 192.168.178.69 and on port 8080 then
ProxyPass / http://192.168.178.69:8080/ would be the correct value.
Next we'll need to link the file we just created to the folder that Apache httpd reads configurations for active sites from.
sudo mkdir /etc/apache2/sites-enabled sudo ln -s /etc/apache2/sites-available/yourgotosocial.url.conf /etc/apache2/sites-enabled/
Now check for configuration errors.
sudo apachectl -t
If everything is fine you should get this as output:
Everything working? Great! Then restart Apache httpd to load your new config file.
sudo systemctl restart apache2
Setting up SSL with mod_md
To setup Apache httpd with mod_md, we'll need to load the module and then modify our vhost files:
MDomain example auto <VirtualHost *:80> ServerName example.com </VirtualHost> <VirtualHost *:443> SSLEngine On ServerName example.com ProxyPreserveHost On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ RequestHeader set "X-Forwarded-Proto" expr=https </VirtualHost>
This allows mod_md to take care of the SSL setup, and it will also redirect from http to https. After we put ths into place, we'll need to restart Apache httpd
sudo systemctl restart apache2
and monitor the logs to see when the new certificate arrives, and then reload it one last time and after that you should be good to go!
Apache httpd needs to be restart (or reloaded), every time mod_md gets a new certificate, see the module's docs for more information on that.