Add Caddyfile rather than nginx

This commit is contained in:
Dave Gallant
2022-08-21 17:01:00 +00:00
parent b059b01a0b
commit afa440e765
6 changed files with 14 additions and 36 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
node_modules
dist
backend/bin/
.vscode
*.pem

5
Caddyfile Normal file
View File

@@ -0,0 +1,5 @@
rfd.fyi
file_server
reverse_proxy /api/* backend:8080

View File

@@ -10,11 +10,11 @@ COPY . .
RUN yarn build
FROM nginx:stable-alpine as production-stage
FROM caddy:2.5.2-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
WORKDIR /my-site
COPY nginx.conf /etc/nginx/
COPY --from=build-stage /app/dist ./
COPY Caddyfile /etc/caddy/Caddyfile
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

View File

@@ -3,8 +3,10 @@ services:
frontend:
build:
dockerfile: Dockerfile
context: .
ports:
- 80:80
- 443:443
links:
- "backend:backend"
backend:

View File

@@ -1,30 +0,0 @@
events {
worker_connections 1024;
}
http {
upstream backend {
server backend:8080;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
root /usr/share/nginx/html;
}
location /api/ {
proxy_pass http://backend;
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;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}

View File

@@ -39,7 +39,7 @@
></a>
</td>
<td scope="col">{{ topic.total_views }}</td>
<td scope="col">{{ topic.score }}</td>
<!-- <td scope="col">{{ topic.score }}</td> -->
<!-- <td scope="col">{{ topic.votes.up - topic.votes.down }}</td> -->
<td scope="col">{{ formatDate(topic.last_post_time) }}</td>
</tr>