From aa79fbe310de092b71b6ecdd334fadb0436ea7ef Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 7 Dec 2022 08:38:02 +0000 Subject: [PATCH] add to gitignore. --- .gitignore | 1 + Nginx/default.conf | 21 +++- Nginx/default.tpl.conf | 229 +++++++++++++++++++++++++++++++++++++++++ StatusPage/Index.ts | 1 + package.json | 8 +- preinstall.sh | 7 +- 6 files changed, 258 insertions(+), 9 deletions(-) create mode 100644 Nginx/default.tpl.conf diff --git a/.gitignore b/.gitignore index 3317bbb3d0..b05fbaaece 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ logs.txt */Cert.crt */Key.key +Nginx/default.conf diff --git a/Nginx/default.conf b/Nginx/default.conf index 334abefb5d..a3ea903733 100644 --- a/Nginx/default.conf +++ b/Nginx/default.conf @@ -60,7 +60,20 @@ server { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_pass http://status-page/; + proxy_pass http://status-page; + } + + location /status-page { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://status-page; } location /status-page-api { @@ -73,7 +86,7 @@ server { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_pass http://status-page-api/; + proxy_pass http://status-page-api; } # Acme Verification. @@ -87,14 +100,14 @@ server { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - proxy_pass http://status-page-api/; + proxy_pass http://status-page-api; } } server { listen 443 ssl; # Port HTTPS listen 80; - server_name localhost; + server_name local.oneuptime.com; ssl_certificate /etc/nginx/certs/Cert.crt; ssl_certificate_key /etc/nginx/certs/Key.key; diff --git a/Nginx/default.tpl.conf b/Nginx/default.tpl.conf new file mode 100644 index 0000000000..2936b7594d --- /dev/null +++ b/Nginx/default.tpl.conf @@ -0,0 +1,229 @@ +upstream accounts { + server accounts:3003 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream identity { + server identity:3087 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream file { + server file:3125 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream dashboard-api { + server dashboard-api:3002 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream dashboard { + server dashboard:3009 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream status-page { + server status-page:3105 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream status-page-api { + server status-page:3106 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream home { + server home:1444 weight=10 max_fails=3 fail_timeout=30s; +} + +upstream workers { + server workers:3452 weight=10 max_fails=3 fail_timeout=30s; +} + +server { + listen 443 default_server ssl; # Port HTTPS + + ssl_certificate /etc/nginx/certs/Cert.crt; + ssl_certificate_key /etc/nginx/certs/Key.key; + + listen 80 default_server; + server_name _; # All domains. + + proxy_busy_buffers_size 512k; + proxy_buffers 4 512k; + proxy_buffer_size 256k; + + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + + location / { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://status-page; + } + + location /status-page { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://status-page; + } + + location /status-page-api { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://status-page-api; + } + + # Acme Verification. + location /.well-known { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://status-page-api; + } +} + +server { + listen 443 ssl; # Port HTTPS + listen 80; + server_name {{ .Env.DOMAIN }}; + + ssl_certificate /etc/nginx/certs/Cert.crt; + ssl_certificate_key /etc/nginx/certs/Key.key; + + proxy_busy_buffers_size 512k; + proxy_buffers 4 512k; + proxy_buffer_size 256k; + + fastcgi_buffers 16 16k; + fastcgi_buffer_size 32k; + + location / { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://home/; + } + + location /accounts { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://accounts/; + } + + location /dashboard { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://dashboard/; + } + + location /status-page { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://status-page/; + } + + location /identity { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://identity/; + } + + location /file { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://file/; + + client_max_body_size 50M; + } + + location /api { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://dashboard-api/; + + client_max_body_size 50M; + } + + location /workers { + 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 $scheme; + + # enable WebSockets (for ws://sockjs not connected error in the accounts source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon) + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://workers/; + } +} \ No newline at end of file diff --git a/StatusPage/Index.ts b/StatusPage/Index.ts index 5bbcf02a7e..4224309719 100755 --- a/StatusPage/Index.ts +++ b/StatusPage/Index.ts @@ -54,6 +54,7 @@ app.get( app.get( '/status-page-api/cname-verification/:token', async (req: ExpressRequest, res: ExpressResponse) => { + logger.info("HERE!") const host: string | undefined = req.get('host'); if (!host) { diff --git a/package.json b/package.json index 41ba45b4a6..ddb304090a 100644 --- a/package.json +++ b/package.json @@ -41,10 +41,10 @@ "lint": "ejslint home/views/*.ejs && eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore ", "fix-lint": " node --max_old_space_size=18192 ./node_modules/.bin/eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore --fix ", "fix": "npm run fix-lint", - "start": "docker compose up -d $npm_config_services", - "ps": "docker compose ps", - "logs": "docker compose logs --tail=100 -f $npm_config_services", - "write-logs": "docker compose logs -f $npm_config_services > logs.txt", + "start": "sudo docker compose up -d $npm_config_services", + "ps": "sudo docker compose ps", + "logs": "sudo docker compose logs --tail=100 -f $npm_config_services", + "write-logs": "sudo docker compose logs -f $npm_config_services > logs.txt", "force-build": "npm run prerun && docker compose build --no-cache $npm_config_services", "force-build-dev": "npm run config-to-dev && npm run force-build", "kill": "npm run stop", diff --git a/preinstall.sh b/preinstall.sh index 6e7adfe0fd..5dcd8ace63 100644 --- a/preinstall.sh +++ b/preinstall.sh @@ -155,6 +155,7 @@ ts-node-esm ./Scripts/Install/MergeEnvTemplate.ts cat config.env.temp | gomplate > config.env + rm config.env.temp # Load env values from config.env @@ -174,4 +175,8 @@ for directory_name in $(find . -type d -maxdepth 1) ; do done # Convert template to docker-compose. -cat docker-compose.tpl.yml | gomplate > docker-compose.yml \ No newline at end of file +cat docker-compose.tpl.yml | gomplate > docker-compose.yml + + +# Convert nginx conf template to nginx +cat ./Nginx/default.tpl.conf | gomplate > ./Nginx/default.conf \ No newline at end of file