Split nginx config; added start of gateway routing

astro
Jef Roosens 2021-12-26 09:02:22 +01:00
parent 1d14f39642
commit 7e09e6879c
Signed by: Jef Roosens
GPG Key ID: 955C0660072F691F
5 changed files with 39 additions and 17 deletions

View File

@ -17,8 +17,9 @@ RUN yarn run build
FROM nginx:1.21.4-alpine
# Copy over the Nginx config files
COPY nginx.conf /etc/nginx/nginx.conf
COPY default.conf.template /etc/nginx/templates/default.conf.template
COPY nginx/nginx.conf /etc/nginx/nginx.conf
COPY nginx/*.conf.template /etc/nginx/templates/
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
# Copy over build artifacts
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html

20
nginx/default.conf 100644
View File

@ -0,0 +1,20 @@
# vim: ft=nginx
server {
listen 80;
listen [::]:80;
# =====FRONTEND HOSTING=====
location / {
root /usr/share/nginx/html;
index 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;
}
}

View File

@ -0,0 +1,13 @@
# vim: ft=nginx
server {
listen 80;
listen [::]:80;
location ~ /api/v1/posts/ {
proxy_pass http://${RB_BLOG}/api/v1/posts/;
}
location ~ /api/v1/sections/ {
proxy_pass http://${RB_BLOG}/api/v1/sections/;
}
}

View File

@ -1,6 +1,6 @@
# vim: ft=nginx
server {
listen 80;
listen 80;
listen [::]:80;
@ -52,18 +52,4 @@ server {
return 405;
}
# =====FRONTEND HOSTING=====
location / {
root /usr/share/nginx/html;
index 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;
}
}

View File

@ -27,5 +27,7 @@ http {
gzip on;
# This order is important, as the Matrix matches should be evaluated first
include /etc/nginx/conf.d/matrix.conf;
include /etc/nginx/conf.d/gateway.conf;
include /etc/nginx/conf.d/default.conf;
}