Apache WebServer setup
This will show you how to set up and Apache2 config.
Requirements
- Apache2 WebServer
- Ubuntu 20.04+
Setup
Install Apache2 on your Ubuntu Server 20.04
$ sudo apt install apache2
cd into
/etc/apache2/sites-enabled
$ cd /etc/apache2/sites-enabled
Create a new file called
example.com.conf
$ nano example.com.conf
After opening the
example.com.conf
file, add this. Make sure to replaceexample.com
with your domain name.example.com.conf<VirtualHost *:443>
ServerName bpsapi.rajtech.me
DocumentRoot /var/www/bpsapi.rajtech.me
<Directory "/var/www/bpsapi.rajtech.me">
Require all granted
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =bpsapi.rajtech.me
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/bpsapi.rajtech.me/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/bpsapi.rajtech.me/privkey.pem
</VirtualHost>Save the file and exit.
Create a new file in the same directory called
example.com-le-ssl.conf
$ nano example.com-le-ssl.conf
After opening the
example.com-le-ssl.conf
file, add this. Make sure to replaceexample.com
with your domain name.example.com-le-ssl.conf<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName bpsapi.rajtech.me
DocumentRoot /var/www/bpsapi.rajtech.me
<Directory "/var/www/bpsapi.rajtech.me">
Require all granted
</Directory>
ProxyPass "/api" "http://192.168.100.80:5641"
ProxyPassReverse "/api" "http://192.168.100.80:5641"
SSLCertificateFile /etc/letsencrypt/live/bpsapi.rajtech.me/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/bpsapi.rajtech.me/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
```
Remember to point the
ProxyPass
andProxyPassReverse
to your API's correct node and port. Also make sure to change theAlias
to your correct volume.Find the Pterodactyl absolute path of the API's PNG output folder and put it in the
Alias
andDirectory
tags.Install Let's Encrypt on your Ubuntu Server 20.04
$ sudo apt install certbot python3-certbot-apache
Run the following command to get a certificate for your domain.
$ sudo certbot -d example.com --manual --preferred-challenges dns certonly
You will have to add a TXT record to your domain's DNS records. You can find the record in the output of the command.
After adding the record, press enter to continue.
After the certificate is issued, you can remove the TXT record from your DNS records.
Now, You may restart Apache2 to apply the changes.
$ sudo systemctl restart apache2
You're done! You can now access the API at
https://example.com/api
Thanks for reading!