Skip to content

Commit

Permalink
feat: nginx upstream keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jun 4, 2024
1 parent 9f5e491 commit d3d940c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ FROM $BASE_IMAGE AS build
RUN apt-get update && \
apt-get install -y nginx tini

ARG USER=${USER:-root}

RUN chown -R $USER /var/log/nginx /var/lib/nginx

USER $USER

WORKDIR /opt/openbmclapi
COPY package-lock.json package.json ./
RUN npm ci --omit=dev

COPY --from=install /opt/openbmclapi/dist ./dist
COPY nginx/ /opt/openbmclapi/nginx


ENV CLUSTER_PORT=4000
EXPOSE $CLUSTER_PORT
VOLUME /opt/openbmclapi/cache
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
version: '3'
services:
openbmclapi:
build: .
build:
context: .
dockerfile: Dockerfile
args:
- USER=${UID-1000}
env_file:
- .env
volumes:
- ./cache:/opt/openbmclapi/cache
- ./cache:/opt/openbmclapi/cache
network_mode: host
user: "${UID-1000}:${GID-1000}"
logging:
Expand Down
17 changes: 14 additions & 3 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ http {
default $prefix;
}

upstream openbmclapi {
server unix:<%= sock %>;
keepalive 32;
}

server {
root <%= root %>/cache;

Expand All @@ -38,11 +43,13 @@ http {
}

location @be {
proxy_pass http://unix:<%= sock %>;
proxy_pass http://openbmclapi;
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;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
}

Expand All @@ -59,21 +66,25 @@ http {
}

location / {
proxy_pass http://unix:<%= sock %>;
proxy_pass http://openbmclapi;
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;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_buffering off;
}

location = /auth {
internal;
proxy_pass http://unix:<%= sock %>;
proxy_pass http://openbmclapi;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
proxy_set_header x-openbmclapi-hash $hash;
proxy_http_version 1.1;
proxy_set_header Connection "";
}
}
}

0 comments on commit d3d940c

Please sign in to comment.