|
| 1 | +--- |
| 2 | +sidebar_position: 4 |
| 3 | +--- |
| 4 | +# Apache WebServer setup |
| 5 | + |
| 6 | +This tutorial will help you host the API on the Pterodactyl hosting panel. |
| 7 | + |
| 8 | +:::warning Warning! |
| 9 | + |
| 10 | +This is an advanced topic, and you should only proceed if you know what you're doing. |
| 11 | + |
| 12 | +::: |
| 13 | + |
| 14 | + |
| 15 | +## Requirements |
| 16 | + |
| 17 | +* Apache2 WebServer |
| 18 | +* Ubuntu 20.04+ |
| 19 | + |
| 20 | +## Setup |
| 21 | + |
| 22 | +1. Install Apache2 on your Ubuntu Server 20.04 |
| 23 | + ```bash |
| 24 | + $ sudo apt install apache2 |
| 25 | + ``` |
| 26 | +2. cd into `/etc/apache2/sites-enabled` |
| 27 | + ```bash |
| 28 | + $ cd /etc/apache2/sites-enabled |
| 29 | + ``` |
| 30 | +3. Create a new file called `example.com.conf` |
| 31 | + ```bash |
| 32 | + $ nano example.com.conf |
| 33 | + ``` |
| 34 | + |
| 35 | +4. After opening the `example.com.conf` file, add this. Make sure to replace `example.com` with your domain name. |
| 36 | + `example.com.conf` |
| 37 | + ```apacheconf |
| 38 | + <VirtualHost *:443> |
| 39 | + ServerName bpsapi.rajtech.me |
| 40 | + DocumentRoot /var/www/bpsapi.rajtech.me |
| 41 | +
|
| 42 | + <Directory "/var/www/bpsapi.rajtech.me"> |
| 43 | + Require all granted |
| 44 | + </Directory> |
| 45 | +
|
| 46 | + RewriteEngine on |
| 47 | + RewriteCond %{SERVER_NAME} =bpsapi.rajtech.me |
| 48 | + RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] |
| 49 | + |
| 50 | + Include /etc/letsencrypt/options-ssl-apache.conf |
| 51 | + |
| 52 | + SSLCertificateFile /etc/letsencrypt/live/bpsapi.rajtech.me/fullchain.pem |
| 53 | + SSLCertificateKeyFile /etc/letsencrypt/live/bpsapi.rajtech.me/privkey.pem |
| 54 | + </VirtualHost> |
| 55 | + ``` |
| 56 | + |
| 57 | +5. Save the file and exit. |
| 58 | +6. Create a new file in the same directory called `example.com-le-ssl.conf` |
| 59 | + ```bash |
| 60 | + $ nano example.com-le-ssl.conf |
| 61 | + ``` |
| 62 | +7. After opening the `example.com-le-ssl.conf` file, add this. Make sure to replace `example.com` with your domain name. |
| 63 | + ```apacheconf |
| 64 | + <IfModule mod_ssl.c> |
| 65 | + <VirtualHost *:443> |
| 66 | + ServerName bpsapi.rajtech.me |
| 67 | + DocumentRoot /var/www/bpsapi.rajtech.me |
| 68 | +
|
| 69 | + <Directory "/var/www/bpsapi.rajtech.me"> |
| 70 | + Require all granted |
| 71 | + </Directory> |
| 72 | +
|
| 73 | + ProxyPass "/api" "http://192.168.100.80:5641" |
| 74 | + ProxyPassReverse "/api" "http://192.168.100.80:5641" |
| 75 | +
|
| 76 | + Alias "/circularpng" "/var/lib/pterodactyl/volumes/7653645e-cde3-4fcd-8715-ea4471526a54/circularimages" |
| 77 | +
|
| 78 | + <Directory /var/lib/pterodactyl/volumes/7653645e-cde3-4fcd-8715-ea4471526a54/circularimages> |
| 79 | + Require all granted |
| 80 | + </Directory> |
| 81 | +
|
| 82 | + SSLCertificateFile /etc/letsencrypt/live/bpsapi.rajtech.me/fullchain.pem |
| 83 | + SSLCertificateKeyFile /etc/letsencrypt/live/bpsapi.rajtech.me/privkey.pem |
| 84 | + Include /etc/letsencrypt/options-ssl-apache.conf |
| 85 | + </VirtualHost> |
| 86 | + </IfModule> |
| 87 | +
|
| 88 | + ``` |
| 89 | +8. Remember to point the `ProxyPass` and `ProxyPassReverse` to your API's correct node and port. Also make sure to change the `Alias` to your correct volume. |
| 90 | +9. Find the Pterodactyl absolute path of the API's PNG output folder and put it in the `Alias` and `Directory` tags. |
| 91 | + |
| 92 | +10. Install Let's Encrypt on your Ubuntu Server 20.04 |
| 93 | + ```bash |
| 94 | + $ sudo apt install certbot python3-certbot-apache |
| 95 | + ``` |
| 96 | +11. Run the following command to get a certificate for your domain. |
| 97 | + ```bash |
| 98 | + $ sudo certbot -d example.com --manual --preferred-challenges dns certonly |
| 99 | + ``` |
| 100 | + |
| 101 | +12. 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. |
| 102 | +13. After adding the record, press enter to continue. |
| 103 | +14. After the certificate is issued, you can remove the TXT record from your DNS records. |
| 104 | +15. Now, You may restart Apache2 to apply the changes. |
| 105 | + ```bash |
| 106 | + $ sudo systemctl restart apache2 |
| 107 | + ``` |
| 108 | +16. You're done! You can now access the API at `https://example.com/api` |
| 109 | +
|
| 110 | +
|
| 111 | +--- |
| 112 | +
|
| 113 | +Thanks for reading! |
0 commit comments