diff options
Diffstat (limited to 'blog/2023-10-17-self-hosting-anonymousoverflow.org')
-rw-r--r-- | blog/2023-10-17-self-hosting-anonymousoverflow.org | 191 |
1 files changed, 98 insertions, 93 deletions
diff --git a/blog/2023-10-17-self-hosting-anonymousoverflow.org b/blog/2023-10-17-self-hosting-anonymousoverflow.org index 725316c..1acfb95 100644 --- a/blog/2023-10-17-self-hosting-anonymousoverflow.org +++ b/blog/2023-10-17-self-hosting-anonymousoverflow.org @@ -1,33 +1,37 @@ -+++ -date = 2023-10-17T15:44:45.601627917+00:00 -title = "Self-Hosting AnonymousOverflow" -description = "A quick guide to self-hosting AnonymousOverflow." -+++ - -## Overview - -I recently launched an instance of AnonymousOverflow at -[ao.cleberg.net](https://ao.cleberg.net) and wanted to write a brief post on how -easy it is to install with Docker Compose and Nginx. - -This guide uses Ubuntu server, Docker Compose, and Nginx as a reverse proxy. - -## Installation - -### Docker Compose - -To install AnonymousOverflow, start by creating a directory for the application -and create its `docker-compose.yml` file. - -```sh +#+title: Self-Hosting AnonymousOverflow +#+date: 2023-10-17 + +** Overview +:PROPERTIES: +:CUSTOM_ID: overview +:END: +I recently launched an instance of AnonymousOverflow at [[https://ao.cleberg.net][ao.cleberg.net]] and +wanted to write a brief post on how easy it is to install with Docker Compose +and Nginx. + +This guide uses Ubuntu server, Docker Compose, and Nginx as a reverse +proxy. + +** Installation +:PROPERTIES: +:CUSTOM_ID: installation +:END: +*** Docker Compose +:PROPERTIES: +:CUSTOM_ID: docker-compose +:END: +To install AnonymousOverflow, start by creating a directory for the +application and create its =docker-compose.yml= file. + +#+begin_src sh mkdir ~/anonymousoverflow && cd ~/anonymousoverflow nano docker-compose.yml -``` +#+end_src Within this file, paste the following information. Be sure to change the -`APP_URL`, `JWT_SIGNING_SECRET`, and `ports` to match your needs. +=APP_URL=, =JWT_SIGNING_SECRET=, and =ports= to match your needs. -```yaml +#+begin_src yaml version: '3' services: @@ -40,92 +44,93 @@ services: ports: - '9380:8080' restart: 'always' -``` +#+end_src -Save and exit the file when complete. You can now launch the container and -access it via your local network. +Save and exit the file when complete. You can now launch the container +and access it via your local network. -```sh +#+begin_src sh sudo docker-compose up -d -``` - -### Nginx Reverse Proxy +#+end_src -If you want to access this service outside the local network, I recommend using -Nginx as a reverse proxy. +*** Nginx Reverse Proxy +:PROPERTIES: +:CUSTOM_ID: nginx-reverse-proxy +:END: +If you want to access this service outside the local network, I +recommend using Nginx as a reverse proxy. Let's start by creating a configuration file. -```sh +#+begin_src sh sudo nano /etc/nginx/sites-available/ao -``` +#+end_src -Within this file, paste the following content and repace `ao.example.com` with -your URL. You may need to update the SSL certificate statements if your -certificates are in a different location. +Within this file, paste the following content and repace +=ao.example.com= with your URL. You may need to update the SSL +certificate statements if your certificates are in a different location. -```conf +#+begin_src conf server { - if ($host ~ ^[^.]+\.cleberg\.net$) { - return 301 https://$host$request_uri; - } - - listen [::]:80; - listen 80; - server_name ao.example.com; - return 404; + if ($host ~ ^[^.]+\.cleberg\.net$) { + return 301 https://$host$request_uri; + } + + listen [::]:80; + listen 80; + server_name ao.example.com; + return 404; } server { - listen [::]:443 ssl http2; - listen 443 ssl http2; - server_name ao.example.com; - access_log /var/log/nginx/ao.access.log; - error_log /var/log/nginx/ao.error.log; - - add_header X-Content-Type-Options "nosniff"; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Frame-Options "DENY"; - add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"; - add_header Referrer-Policy "no-referrer"; - - ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; - include /etc/letsencrypt/options-ssl-nginx.conf; - ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; - - location / { - set $upstream_ao http://127.0.0.1:9380; - proxy_pass $upstream_ao; - - proxy_set_header Host $host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection upgrade; - proxy_set_header Accept-Encoding gzip; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Host $http_host; - proxy_set_header X-Forwarded-Uri $request_uri; - proxy_set_header X-Forwarded-Ssl on; - proxy_redirect http:// $scheme://; - proxy_http_version 1.1; - proxy_set_header Connection ""; - proxy_cache_bypass $cookie_session; - proxy_no_cache $cookie_session; - proxy_buffers 64 256k; - } + listen [::]:443 ssl http2; + listen 443 ssl http2; + server_name ao.example.com; + access_log /var/log/nginx/ao.access.log; + error_log /var/log/nginx/ao.error.log; + + add_header X-Content-Type-Options "nosniff"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Frame-Options "DENY"; + add_header Strict-Transport-Security "max-age=63072000; includeSubDomains"; + add_header Referrer-Policy "no-referrer"; + + ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; + include /etc/letsencrypt/options-ssl-nginx.conf; + ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; + + location / { + set $upstream_ao http://127.0.0.1:9380; + proxy_pass $upstream_ao; + + proxy_set_header Host $host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection upgrade; + proxy_set_header Accept-Encoding gzip; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Forwarded-Uri $request_uri; + proxy_set_header X-Forwarded-Ssl on; + proxy_redirect http:// $scheme://; + proxy_http_version 1.1; + proxy_set_header Connection ""; + proxy_cache_bypass $cookie_session; + proxy_no_cache $cookie_session; + proxy_buffers 64 256k; + } } -``` +#+end_src Save and exit the file when complete. On Ubuntu, you will need to symlink the -configuration file before it will be recognized by Nginx. Once complete, -simply restart the web server. +configuration file before it will be recognized by Nginx. Once complete, simply +restart the web server. -```sh +#+begin_src sh sudo ln -s /etc/nginx/sites-available/ao /etc/nginx/sites-enabled/ao sudo systemctl restart nginx.service -``` +#+end_src -The website will now be available publicly. Visit -[my instance](https://ao.cleberg.net) for an example. +The website will now be available publicly. Visit [[https://ao.cleberg.net][my instance]] for an example. |