Skip to content

Commit f2c591b

Browse files
committed
Add Apache Guide + minor improvements
1 parent 24cb2ca commit f2c591b

File tree

3 files changed

+115
-30
lines changed

3 files changed

+115
-30
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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!

docs/API/hosting-the-api/getting-ready.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ sidebar_position: 1
77
In this section, you will learn how to get the environment ready to run the API.
88

99
You can either host it on Pterodactyl or run it locally.
10+
You will also need a working web-server configuration for the png generation to work.
1011

1112
:::warning Hosting the API requires basic CS knowledge.
1213

docs/API/hosting-the-api/hosting-on-pterodactyl.md

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,7 @@ This is an advanced topic, and you should only proceed if you know what you're d
2626
5. After the server is created and the auto-installation has completed, put in the API files from [Our Repository](https://github.com/BPS-Circular-API/api)
2727
6. Make sure the main API file is `main.py`
2828
7. Click the run button. The server should start up
29-
8. Now, You will need to route the API port using your web-server, here I will be using Apache2 on Ubuntu Server 20.04.
30-
9. Set the `example.com.conf` up in `/etc/apache2/sites-enabled`, and then add this apache config. Remember to replace `example.com` with your domain name.
31-
32-
`example.com-le-ssl.conf`
33-
```apacheconf
34-
<IfModule mod_ssl.c>
35-
<VirtualHost *:443>
36-
ServerName example.com
37-
DocumentRoot /var/www/example.com
38-
39-
<Directory "/var/www/example.com">
40-
Require all granted
41-
</Directory>
42-
43-
ProxyPass /api/ "http:<local-device-ip>:<api-port>"
44-
ProxyPassReverse /api/ "http:<local-device-ip>:<api-port>"
45-
46-
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
47-
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
48-
Include /etc/letsencrypt/options-ssl-apache.conf
49-
50-
</VirtualHost>
51-
</IfModule>
52-
53-
```
54-
55-
10. After doing this, restart your server. It should start up normally.
56-
11. Now generate SSL certificates for the domain. Using the [Let's Encrypt](https://letsencrypt.org/) service. If the normal method fails, you can try to try to use the DNS challenge method.
57-
12. Restart your web-server again.
58-
13. All should now be set up.
29+
8. Congratulations! You have successfully hosted the API on Pterodactyl!
5930

6031
---
6132

0 commit comments

Comments
 (0)