Merge pull request 'Add nginx support' (#2) from nginx into master
Reviewed-on: #2
This commit is contained in:
commit
1d88e5c723
|
@ -2,6 +2,9 @@
|
||||||
This is a rewrite of my current website to Express.JS.
|
This is a rewrite of my current website to Express.JS.
|
||||||
[Git repo](https://git.blek.codes/blek/homepage.js) | [Website](https://blek.codes)
|
[Git repo](https://git.blek.codes/blek/homepage.js) | [Website](https://blek.codes)
|
||||||
|
|
||||||
|
# Warning: This branch is __experimental__
|
||||||
|
### This branch is untested and unstable, and probably won't work in production.
|
||||||
|
### Please don't use it for other purposes that development.
|
||||||
# Running an instance
|
# Running an instance
|
||||||
|
|
||||||
First, [generate the app key](#generate-the-key).
|
First, [generate the app key](#generate-the-key).
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
|
@ -0,0 +1,49 @@
|
||||||
|
types {
|
||||||
|
text/html html htm shtml;
|
||||||
|
text/css css;
|
||||||
|
text/xml xml rss;
|
||||||
|
image/gif gif;
|
||||||
|
image/jpeg jpeg jpg;
|
||||||
|
application/x-javascript js;
|
||||||
|
text/plain txt;
|
||||||
|
text/x-component htc;
|
||||||
|
text/mathml mml;
|
||||||
|
image/png png;
|
||||||
|
image/x-icon ico;
|
||||||
|
image/x-jng jng;
|
||||||
|
image/vnd.wap.wbmp wbmp;
|
||||||
|
image/svg+xml svg svgz;
|
||||||
|
application/java-archive jar war ear;
|
||||||
|
application/mac-binhex40 hqx;
|
||||||
|
application/pdf pdf;
|
||||||
|
application/x-cocoa cco;
|
||||||
|
application/x-java-archive-diff jardiff;
|
||||||
|
application/x-java-jnlp-file jnlp;
|
||||||
|
application/x-makeself run;
|
||||||
|
application/x-perl pl pm;
|
||||||
|
application/x-pilot prc pdb;
|
||||||
|
application/x-rar-compressed rar;
|
||||||
|
application/x-redhat-package-manager rpm;
|
||||||
|
application/x-sea sea;
|
||||||
|
application/x-shockwave-flash swf;
|
||||||
|
application/x-stuffit sit;
|
||||||
|
application/x-tcl tcl tk;
|
||||||
|
application/x-x509-ca-cert der pem crt;
|
||||||
|
application/x-xpinstall xpi;
|
||||||
|
application/zip zip;
|
||||||
|
application/octet-stream deb;
|
||||||
|
application/octet-stream bin exe dll;
|
||||||
|
application/octet-stream dmg;
|
||||||
|
application/octet-stream eot;
|
||||||
|
application/octet-stream iso img;
|
||||||
|
application/octet-stream msi msp msm;
|
||||||
|
audio/mpeg mp3;
|
||||||
|
audio/x-realaudio ra;
|
||||||
|
video/mpeg mpeg mpg;
|
||||||
|
video/quicktime mov;
|
||||||
|
video/x-flv flv;
|
||||||
|
video/x-msvideo avi;
|
||||||
|
video/x-ms-wmv wmv;
|
||||||
|
video/x-ms-asf asx asf;
|
||||||
|
video/x-mng mng;
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
user nobody nobody;
|
||||||
|
worker_processes 4;
|
||||||
|
error_log logs/error.log;
|
||||||
|
pid logs/nginx.pid;
|
||||||
|
worker_rlimit_nofile 8192;
|
||||||
|
|
||||||
|
events {
|
||||||
|
worker_connections 4096; ## Default: 1024
|
||||||
|
}
|
||||||
|
|
||||||
|
http {
|
||||||
|
include mime.types;
|
||||||
|
include proxy.conf;
|
||||||
|
index index.html index.htm;
|
||||||
|
|
||||||
|
default_type application/octet-stream;
|
||||||
|
log_format main '$remote_addr - $remote_user [$time_local] $status '
|
||||||
|
'"$request" $body_bytes_sent "$http_referer" '
|
||||||
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||||
|
access_log logs/access.log main;
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
|
||||||
|
|
||||||
|
gzip on;
|
||||||
|
gzip_types text/plain application/json application/x-json application/javascript application/x-javascript text/css text/x-css;
|
||||||
|
gzip_min_length 1024;
|
||||||
|
gzip_static on;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
location / {
|
||||||
|
proxy_pass http://server;
|
||||||
|
}
|
||||||
|
location /static {
|
||||||
|
root /var/www;
|
||||||
|
gzip_static on;
|
||||||
|
}
|
||||||
|
location /announce.json/ {
|
||||||
|
root /var/www;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
client_max_body_size 10m;
|
||||||
|
client_body_buffer_size 128k;
|
||||||
|
proxy_connect_timeout 90;
|
||||||
|
proxy_send_timeout 90;
|
||||||
|
proxy_read_timeout 90;
|
||||||
|
proxy_buffers 32 4k;
|
|
@ -7,7 +7,6 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- './:/opt/code'
|
- './:/opt/code'
|
||||||
ports:
|
ports:
|
||||||
- '${APP_PORT}:${APP_PORT}'
|
|
||||||
- '9229:9229'
|
- '9229:9229'
|
||||||
env_file: ./.env
|
env_file: ./.env
|
||||||
environment:
|
environment:
|
||||||
|
@ -21,6 +20,15 @@ services:
|
||||||
- '6379:6379'
|
- '6379:6379'
|
||||||
networks:
|
networks:
|
||||||
- homepage
|
- homepage
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
ports:
|
||||||
|
- '${APP_PORT}:80'
|
||||||
|
networks:
|
||||||
|
- homepage
|
||||||
|
volumes:
|
||||||
|
- './config/nginx:/etc/nginx'
|
||||||
|
- './public:/var/www:ro'
|
||||||
db:
|
db:
|
||||||
image: postgres:alpine
|
image: postgres:alpine
|
||||||
ports:
|
ports:
|
||||||
|
|
|
@ -7,8 +7,6 @@ services:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- './:/opt/code'
|
- './:/opt/code'
|
||||||
ports:
|
|
||||||
- '${APP_PORT}:${APP_PORT}'
|
|
||||||
env_file: ./.env
|
env_file: ./.env
|
||||||
environment:
|
environment:
|
||||||
APP_PORT: '${APP_PORT}'
|
APP_PORT: '${APP_PORT}'
|
||||||
|
@ -19,6 +17,15 @@ services:
|
||||||
image: redis:alpine
|
image: redis:alpine
|
||||||
networks:
|
networks:
|
||||||
- homepage
|
- homepage
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
ports:
|
||||||
|
- '${APP_PORT}:80'
|
||||||
|
networks:
|
||||||
|
- homepage
|
||||||
|
volumes:
|
||||||
|
- './config/nginx:/etc/nginx'
|
||||||
|
- './public:/var/www:ro'
|
||||||
db:
|
db:
|
||||||
restart: always
|
restart: always
|
||||||
image: postgres:alpine
|
image: postgres:alpine
|
||||||
|
|
4
index.js
4
index.js
|
@ -13,7 +13,9 @@ const app = express();
|
||||||
const session = require('express-session');
|
const session = require('express-session');
|
||||||
const bodyparser = require('body-parser');
|
const bodyparser = require('body-parser');
|
||||||
|
|
||||||
const { APP_PORT } = process.env;
|
// this runs behind nginx now, which handles
|
||||||
|
// the external port
|
||||||
|
const APP_PORT = 80; // process.env;
|
||||||
|
|
||||||
app.set('trust proxy', process.env.TRUST_PROXY);
|
app.set('trust proxy', process.env.TRUST_PROXY);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue