Skip to content

Commit

Permalink
Adding sample NGINX configurations, and associated "instructions" to …
Browse files Browse the repository at this point in the history
…/doc/README.MD
  • Loading branch information
BanjoFox committed Jan 25, 2018
1 parent e752066 commit a4c43e0
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 0 deletions.
75 changes: 75 additions & 0 deletions config/nginx/aardwolf-nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

server {
listen 80;
listen [::]:80;
server_name localhost aardwolf-dev.social;

# Setting root to /web because that is where
# static files will (probably) live
root /web;

# Useful for Let's Encrypt
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name localhost aardwolf-dev.social;

####################
# SECURITY WARNING #
####################
#
# Providing a state of the art TLS configuration
# is beyond the scope of this documentation.
#
# You need to replace this comment with a proper
# ssl configuration template for nginx.
#
# If you don't know were to start, you can get one here :
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
#
# This configuration file won't work without ssl configuration directives.

keepalive_timeout 70;
sendfile on;
client_max_body_size 0;

# Setting root to /web because that is where
# static files will (probably) live
root /web;

include includes/gzip.conf;

location / {
try_files $uri @proxy;
}

include includes/other-locations.conf;

location @proxy {
proxy_set_header Host $host;
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 https;
proxy_set_header Proxy "";
proxy_pass_header Server;

proxy_pass http://127.0.0.1:7878;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

tcp_nodelay on;
}

error_page 500 501 502 503 504 /500.html;
}
8 changes: 8 additions & 0 deletions config/nginx/includes/gzip.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
26 changes: 26 additions & 0 deletions config/nginx/includes/other-locations.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
location ~ ^/(emoji|javascript|static|stylesheets|themes) {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri @proxy;
}

location /sw.js {
add_header Cache-Control "public, max-age=0";
try_files $uri @proxy;
}

location /api/v1/streaming {
proxy_set_header Host $host;
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 https;
proxy_set_header Proxy "";

proxy_pass http://127.0.0.1:4000;
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

tcp_nodelay on;
}
23 changes: 23 additions & 0 deletions config/nginx/troubleshooting.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 8000;
listen [::]:8000;
server_name basic.site;

# root /web;

location / {
try_files $uri @proxy;
}

location = /favicon.ico {
alias /home/quixote/gits/aardwolf-testing/web/favicon.ico;
}

location ~ ^/(emoji|javascript|static|stylesheets|themes) {
try_files /home/quixote/gits/aardwolf-testing/web/ $uri;
}

location @proxy {
proxy_pass http://127.0.0.1:7878;
}
}
34 changes: 34 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# Documentation
This folder contains documentation for configuring and running the Aardwolf software, to be included in distribution packages. This includes [manual pages](https://en.wikipedia.org/wiki/Man_page).

## NGINX Configuration
Because Rocket isn't really designed to serve static files (i.e. CSS, images, etc.) it is necessary to use a web server application. Banjo's favorite is NGINX because its FAST, and does not require reams of paper to print configurations ;) (most of the time).<br />

`../config/nginx/aardwolf-nginx.conf` -- This is the "server" block, which is basically a clone of the Mastodon config (Banjo is extreeeemely lazy...) but without all the "cruft"
`../config/nginx/includes/gzip.conf` -- This is the GZIP compression info
`../config/nginx/includes/other-locations.conf` -- These are for other locations to add non-critical functionality. It was easier to put them here so that a single line comment `#include includes/other-locations.conf` could be done to make troubleshooting easier ;)

### Setting up NGINX - The fast way (FUTURE)
Debian:

```
$ sudo apt-get install nginx
$ sudo mkdir /etc/nginx/includes
$ sudo cp [path_to_aardwolf_repo]/config/nginx/aardwolf-nginx.conf /etc/nginx/sites-available/
$ sudo cp [path_to_aardwolf_repo]/config/nginx/includes/* /etc/nginx/includes/
$ sudo /etc/nginx/sites-available/aardwolf-nginx.conf /etc/nginx/sites-enabled/aardwolf-nginx.conf
$ sudo nginx -s reload
```
Then browse to `http://localhost` :D


### The TROUBLESHOOTING way -- (Because locations are still mostly broken v.v)
$ sudo apt-get install nginx
$ sudo mkdir /etc/nginx/includes
$ sudo cp [path_to_aardwolf_repo]/config/nginx/troubleshooting.conf /etc/nginx/sites-available/
$ sudo cp [path_to_aardwolf_repo]/config/nginx/includes/* /etc/nginx/includes/
$ sudo /etc/nginx/sites-available/troubleshooting.conf /etc/nginx/sites-enabled/troubleshooting.conf
$ sudo nginx -s reload
```
Then browse to `http://localhost:8000`, and try to figure out what borked D:
Empty file removed lang/en_us
Empty file.

0 comments on commit a4c43e0

Please sign in to comment.