From aa5c0f81d3a1023a4c6859e9f92fb04a64a2a99b Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 23 Aug 2024 09:46:45 -0700 Subject: [PATCH 1/4] Docker config --- Docker/.gitignore | 2 ++ Docker/client.Dockerfile | 2 +- Docker/docker-compose.yaml | 12 ++++++++- Docker/nginx/conf.d/default.conf | 33 +++++++++++++++++++++++ Docker/nginx/default.conf | 45 -------------------------------- 5 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 Docker/nginx/conf.d/default.conf delete mode 100644 Docker/nginx/default.conf diff --git a/Docker/.gitignore b/Docker/.gitignore index e1b726025..80c983e6f 100644 --- a/Docker/.gitignore +++ b/Docker/.gitignore @@ -2,4 +2,6 @@ !build_images.sh mongo/data/* redis/data/* +nginx/* +certbot/* *.env \ No newline at end of file diff --git a/Docker/client.Dockerfile b/Docker/client.Dockerfile index aaea43c06..0f7935cd1 100644 --- a/Docker/client.Dockerfile +++ b/Docker/client.Dockerfile @@ -16,7 +16,7 @@ RUN npm run build FROM nginx:1.27.1-alpine -COPY ./Docker/nginx/default.conf /etc/nginx/conf.d/default.conf +# COPY ./Docker/nginx/default.conf /etc/nginx/conf.d/default.conf COPY --from=build /app/dist /usr/share/nginx/html CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/Docker/docker-compose.yaml b/Docker/docker-compose.yaml index 1abbce9d4..c9fa3431f 100644 --- a/Docker/docker-compose.yaml +++ b/Docker/docker-compose.yaml @@ -1,11 +1,21 @@ -version: "3" services: client: image: uptime_client:latest ports: - "80:80" + - "443:443" depends_on: - server + volumes: + - ./nginx/conf.d:/etc/nginx/conf.d/:ro + - ./certbot/www:/var/www/certbot/:ro + - ./certbot/conf/:/etc/nginx/ssl/:ro + + certbot: + image: certbot/certbot:latest + volumes: + - ./certbot/www/:/var/www/certbot/:rw + - ./certbot/conf/:/etc/letsencrypt/:rw server: image: uptime_server:latest ports: diff --git a/Docker/nginx/conf.d/default.conf b/Docker/nginx/conf.d/default.conf new file mode 100644 index 000000000..eb06e2746 --- /dev/null +++ b/Docker/nginx/conf.d/default.conf @@ -0,0 +1,33 @@ +server { + listen 80; + listen [::]:80; + + server_name uptime-demo.bluewavelabs.ca; + server_tokens off; + + location /.well-known/acme-challenge/ { + root /var/www/certbot; + } + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } +} + +server { + listen 443 default_server ssl http2; + listen [::]:443 ssl http2; + + server_name uptime-demo.bluewavelabs.ca; + + ssl_certificate /etc/nginx/ssl/live/uptime-demo.bluewavelabs.ca/fullchain.pem; + ssl_certificate_key /etc/nginx/ssl/live/uptime-demo.bluewavelabs.ca/privkey.pem; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } +} diff --git a/Docker/nginx/default.conf b/Docker/nginx/default.conf deleted file mode 100644 index 0c3122df3..000000000 --- a/Docker/nginx/default.conf +++ /dev/null @@ -1,45 +0,0 @@ -server { - listen 80; - listen [::]:80; - server_name localhost; - - #access_log /var/log/nginx/host.access.log main; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - try_files $uri $uri/ /index.html; - } - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - - # proxy the PHP scripts to Apache listening on 127.0.0.1:80 - # - #location ~ \.php$ { - # proxy_pass http://127.0.0.1; - #} - - # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 - # - #location ~ \.php$ { - # root html; - # fastcgi_pass 127.0.0.1:9000; - # fastcgi_index index.php; - # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; - # include fastcgi_params; - #} - - # deny access to .htaccess files, if Apache's document root - # concurs with nginx's one - # - #location ~ /\.ht { - # deny all; - #} -} From ab0e3c4d0a96df8cf5f1eb341ba6dbd554fcf450 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 23 Aug 2024 09:58:46 -0700 Subject: [PATCH 2/4] update nginx conf --- Docker/nginx/conf.d/default.conf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Docker/nginx/conf.d/default.conf b/Docker/nginx/conf.d/default.conf index eb06e2746..8fdc625ee 100644 --- a/Docker/nginx/conf.d/default.conf +++ b/Docker/nginx/conf.d/default.conf @@ -14,6 +14,15 @@ server { index index.html index.htm; try_files $uri $uri/ /index.html; } + + location /api/ { + proxy_pass http://server:5000/api; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } } server { @@ -30,4 +39,13 @@ server { index index.html index.htm; try_files $uri $uri/ /index.html; } + + location /api/ { + proxy_pass http://server:5000/api; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + } } From 5d734d477c4e2394c9c95f683a20d8421cb520dd Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 23 Aug 2024 10:10:03 -0700 Subject: [PATCH 3/4] Update nginx conf --- Docker/nginx/conf.d/default.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Docker/nginx/conf.d/default.conf b/Docker/nginx/conf.d/default.conf index 8fdc625ee..027416590 100644 --- a/Docker/nginx/conf.d/default.conf +++ b/Docker/nginx/conf.d/default.conf @@ -18,10 +18,10 @@ server { location /api/ { proxy_pass http://server:5000/api; proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; + 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; } } @@ -43,9 +43,9 @@ server { location /api/ { proxy_pass http://server:5000/api; proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; - proxy_cache_bypass $http_upgrade; + 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; } } From e32f725e29d622e0a628a3b9931369260faf20f7 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 23 Aug 2024 10:12:23 -0700 Subject: [PATCH 4/4] add trailing slash --- Docker/nginx/conf.d/default.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/nginx/conf.d/default.conf b/Docker/nginx/conf.d/default.conf index 027416590..a04d32c87 100644 --- a/Docker/nginx/conf.d/default.conf +++ b/Docker/nginx/conf.d/default.conf @@ -16,7 +16,7 @@ server { } location /api/ { - proxy_pass http://server:5000/api; + proxy_pass http://server:5000/api/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -41,7 +41,7 @@ server { } location /api/ { - proxy_pass http://server:5000/api; + proxy_pass http://server:5000/api/; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;