configure this to run behind nginx

This commit is contained in:
b1ek 2023-06-06 14:09:40 +10:00 committed by blek
parent 662f5197e4
commit 6b7e121e56
Signed by: blek
GPG Key ID: 14546221E3595D0C
7 changed files with 111 additions and 4 deletions

2
config/nginx/logs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

49
config/nginx/mime.types Normal file
View File

@ -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;
}

31
config/nginx/nginx.conf Normal file
View File

@ -0,0 +1,31 @@
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
server {
listen 80;
location / {
proxy_pass http://server;
}
}
}

10
config/nginx/proxy.conf Normal file
View File

@ -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;

View File

@ -7,7 +7,6 @@ services:
volumes:
- './:/opt/code'
ports:
- '${APP_PORT}:${APP_PORT}'
- '9229:9229'
env_file: ./.env
environment:
@ -21,6 +20,14 @@ services:
- '6379:6379'
networks:
- homepage
nginx:
image: nginx:alpine
ports:
- '${APP_PORT}:80'
networks:
- homepage
volumes:
- './config/nginx:/etc/nginx'
db:
image: postgres:alpine
ports:

View File

@ -7,8 +7,6 @@ services:
dockerfile: Dockerfile
volumes:
- './:/opt/code'
ports:
- '${APP_PORT}:${APP_PORT}'
env_file: ./.env
environment:
APP_PORT: '${APP_PORT}'
@ -19,6 +17,14 @@ services:
image: redis:alpine
networks:
- homepage
nginx:
image: nginx:alpine
ports:
- '${APP_PORT}:80'
networks:
- homepage
volumes:
- './config/nginx:/etc/nginx'
db:
restart: always
image: postgres:alpine

View File

@ -13,7 +13,9 @@ const app = express();
const session = require('express-session');
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);