mirror of
https://github.com/httpjamesm/AnonymousOverflow.git
synced 2024-12-06 19:16:43 +01:00
Created Deployment (markdown)
+85
@@ -0,0 +1,85 @@
|
||||
The more hosted instances of AnonymousOverflow we have, the better load will be balanced between them all, leading to a better experience for everyone.
|
||||
|
||||
# Pre-requisites
|
||||
|
||||
* Server or an always-on computer
|
||||
* Fast internet connection
|
||||
|
||||
# Dependencies
|
||||
|
||||
AnonymousOverflow is deployed using Docker. Docker containerizes the app for a more convenient and secure deployment.
|
||||
|
||||
## Install Docker
|
||||
|
||||
If you don't have Docker already, follow the [official documentation](https://docs.docker.com/engine/install/) to install the engine.
|
||||
|
||||
## Clone the repo
|
||||
|
||||
1. Find a directory to put AnonymousOverflow's source code.
|
||||
2. Clone the repo with `git clone https://github.com/httpjamesm/AnonymousOverflow`.
|
||||
|
||||
# Setup Compose
|
||||
|
||||
AnonymousOverflow provides an example docker-compose file in `docker-compose.example.yml`. This defines the setup for the container.
|
||||
|
||||
1. Copy it to `docker-compose.yml` using `cp docker-compose.example.yml docker-compose.yml`.
|
||||
2. Modify ports if needed.
|
||||
* Usually you want to edit the `ports:` section to meet your needs, especially if you're using a reverse proxy, like nginx. Try replacing the `- 80:8080` part with `- host:port:8080`.
|
||||
3. Modify `environment:` to fit your setup.
|
||||
|
||||
# Build and deploy
|
||||
|
||||
In the same directory as the `docker-compose.yml` file, run `docker compose up -d --build` to run the container in the background as a daemon (`-d`) and compile it (`--build`).
|
||||
|
||||
# Optional: Place a reverse proxy in front of it
|
||||
|
||||
Reverse proxies are especially useful if you want to run multiple services on your machine. `nginx` is recommended.
|
||||
|
||||
## Install nginx
|
||||
|
||||
You can install it for your operating system according to the [official documentation](https://www.nginx.com/resources/wiki/start/topics/tutorials/install/).
|
||||
|
||||
## Setup the config file
|
||||
|
||||
Depending on your operating system, this path may differ, but usually configs are stored in `/etc/nginx/sites-enabled`. Navigate to this directory and create a new file called `<domain>.conf`.
|
||||
|
||||
In this file, put the following:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
server_name domain;
|
||||
|
||||
ssl_certificate /etc/ssl/cert.pem;
|
||||
ssl_certificate_key /etc/ssl/key.pem;
|
||||
|
||||
location /static/ {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate" always;
|
||||
add_header Pragma "no-cache" always;
|
||||
add_header Expires "0" always;
|
||||
proxy_pass http://host:port/static/;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
proxy_pass http://host:port;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The `/static/` block is added to put additional cache headers to prevent visual bugs during updates, but this isn't required.
|
||||
|
||||
`$remote_addr` is passed to the app via `X-Forwarded-For` to enforce the anti-scraping ratelimit properly. If you remove this block, it may block access globally if your instance is abused.
|
||||
|
||||
## Reload
|
||||
|
||||
Run `nginx -t` to test your config. If all is ok, it should print the following:
|
||||
|
||||
```
|
||||
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
|
||||
nginx: configuration file /etc/nginx/nginx.conf test is successful
|
||||
```
|
||||
|
||||
If there are no issues, reload using `nginx -s reload`.
|
||||
Reference in New Issue
Block a user