Skip to content

Commit

Permalink
feat(nginx-json): new nginx optimized for serving JSON content effici…
Browse files Browse the repository at this point in the history
…ently
  • Loading branch information
alimd committed Nov 26, 2023
1 parent bfc0c5c commit 418b2d5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nginx-json/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!etc/nginx/
!data/
39 changes: 39 additions & 0 deletions nginx-json/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ghcr.io/alwatr/nginx-core:2.0.0

RUN rm -fv index.html _error.html
COPY etc/nginx/ /etc/nginx/
COPY data/ .
RUN ls -RlahF /etc/nginx /data

# Default environment for nginx template
ENV NGINX_CLIENT_MAX_BODY_SIZE=1k \
NGINX_SENDFILE=on \
NGINX_SENDFILE_MAX_CHUNK=2m \
NGINX_TCP_NOPUSH=on \
NGINX_TCP_NODELAY=on \
NGINX_OPEN_FILE_CACHE="max=5000 inactive=1h" \
NGINX_OPEN_FILE_CACHE_VALID=1s \
NGINX_OPEN_FILE_CACHE_MIN_USES=2 \
NGINX_OUTPUT_BUFFERS="8 8k" \
NGINX_EXPIRES_DYNAMIC=epoch \
NGINX_EXPIRES_STATIC=max \
NGINX_EXPIRES_DEFAULT=epoch \
NGINX_LIMIT_REQ_RATE=400 \
NGINX_LIMIT_REQ_BURST=1000 \
NGINX_DISABLE_SYMLINKS=if_not_owner

ARG BUILD_REV
ARG BUILD_DATE
LABEL org.opencontainers.image.title="alwatr/nginx-ws" \
org.opencontainers.image.description="This is a high-performance version of NGINX, which has been enhanced by Alwatr for the purpose of serving JSON content efficiently." \
org.opencontainers.image.base.name="ghcr.io/alwatr/nginx-core:2.0.0" \
org.opencontainers.image.version="2.0.0" \
org.opencontainers.image.ref.name="2.0.0-nginx1.25.3-alpine3.18-slim" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.created=${BUILD_DATE} \
org.opencontainers.image.revision=${BUILD_REV} \
org.opencontainers.image.vendor="Alwatr" \
org.opencontainers.image.source="https://github.com/Alwatr/nginx" \
org.opencontainers.image.url="https://github.com/Alwatr/nginx" \
org.opencontainers.image.documentation="https://github.com/Alwatr/nginx" \
org.opencontainers.image.authors="S. Ali Mihandoost <[email protected]> (https://ali.mihandoost.com), S. Amir Mohammad Najafi <[email protected]> (https://njfamirm.ir/)"
9 changes: 9 additions & 0 deletions nginx-json/data/error.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ok": false,
"statusCode": <!--# echo var="status" default="500" -->,
"errorCode": "serve_error",
"meta": {
"server": "alwatr/storage",
"status": "<!--# echo var="status_text" default="Something goes wrong." -->"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /_error.json;

location = /_error.json {
internal;
ssi on;
ssi_types *;
auth_basic off;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
location = / {
# return static json for home page
default_type application/json;
return 200 '{"ok": true, "data": "..:: Alwatr Accelerated Storage Server ::.."}';
}

0 comments on commit 418b2d5

Please sign in to comment.