UPD nginx now redirects calls to codex api

This commit is contained in:
Shaun Orssaud 2023-11-02 16:07:01 +09:00
parent 34fc66b7d5
commit c72ad73aab
5 changed files with 44 additions and 29 deletions

View File

@ -12,5 +12,6 @@ RUN yarn build --production
FROM nginx:stable-alpine FROM nginx:stable-alpine
COPY --from=build-step /frontend/build /usr/share/nginx/html COPY --from=build-step /frontend/build /usr/share/nginx/html
EXPOSE 80 EXPOSE 80
COPY deployment/nginx.conf /etc/nginx/conf.d/.conf COPY deployment/nginx.template /etc/nginx/nginx.template
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,21 +1,21 @@
events {} server
http
{ {
server listen 80;
{ server_name localhost;
listen 80;
server_name localhost; root /usr/share/nginx/html;
index index.html;
location /api { error_page 500 502 503 504 /50x.html;
proxy_pass http://localhost:8080;
proxy_set_header Host $host; location /api {
proxy_set_header X-Real-IP $remote_addr; proxy_pass $codex_url;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Real-IP $remote_addr;
} proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / { proxy_set_header X-Forwarded-Proto $scheme;
try_files $uri /index.html; }
add_header Cache-Control "no-cache"; location / {
} try_files $uri /index.html;
add_header Cache-Control "no-cache";
} }
} }

21
deployment/nginx.template Normal file
View File

@ -0,0 +1,21 @@
server
{
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
error_page 500 502 503 504 /50x.html;
location /api {
proxy_pass $codex_url;
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;
}
location / {
try_files $uri /index.html;
add_header Cache-Control "no-cache";
}
}

View File

@ -7,13 +7,6 @@ services:
ports: ports:
- "3000:80" - "3000:80"
environment: environment:
- CODEX=http://localhost:8080 - codex_url=http://host.docker.internal:8080
nginx:
image: nginx:alpine
volumes: volumes:
- ./deployment/nginx.conf:/etc/nginx/nginx.conf:ro - ./deployment/nginx.template:/etc/nginx/templates/10-variables.conf.template:ro
ports:
- "8070:80"
depends_on:
- client

View File

@ -19,7 +19,7 @@ function DebugPage() {
useEffect(() => { useEffect(() => {
axios axios
.get( .get(
`/api/api/codex/v1/debug/info`, `/api/codex/v1/debug/info`,
{ {
headers: headers:
(nodeInfo.auth && { (nodeInfo.auth && {