Skip to content

Commit

Permalink
add nginx configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
user committed Dec 1, 2023
1 parent 61d1409 commit 5fffec6
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ services:
ghost-proxy:
image: ghostcms-web
build: nginx
environment:
NODE_ENV: production
ports:
- "8080:80"

Expand Down
5 changes: 5 additions & 0 deletions nginx/40-enable-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

if [ "$NODE_ENV" = "production" ]; then
sed -i 's/#include/include/g' /etc/nginx/conf.d/default.conf
fi
6 changes: 6 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:1.25-alpine

COPY etc/ /etc/nginx/
COPY 40-enable-cache.sh /docker-entrypoint.d/

RUN chmod 555 /docker-entrypoint.d/40-enable-cache.sh
36 changes: 36 additions & 0 deletions nginx/etc/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# Creates cache
#include snippets/cache_key;

server {
listen 80;
server_name localhost;

#access_log /var/log/nginx/host.access.log main;

root /usr/share/nginx/html;

# enables caching
#include snippets/proxy_params;

location / {
proxy_pass http://ghost:2368;
}

#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;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one

location ~ /\.ht {
deny all;
}

}
2 changes: 2 additions & 0 deletions nginx/etc/snippets/cache_key
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
proxy_cache_path /etc/nginx/cache levels=1:2 keys_zone=GHOST:100m inactive=1m;
proxy_cache_key "$scheme$request_method$host$request_uri";
10 changes: 10 additions & 0 deletions nginx/etc/snippets/proxy_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
proxy_set_header Host $http_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_set_header X-Proxy-Cache $upstream_cache_status;

proxy_cache_lock on;

proxy_cache GHOST;
proxy_cache_valid 200 5s;

0 comments on commit 5fffec6

Please sign in to comment.