~jeffa/jeffa.io

e50e951ee93e117b4cc21c3f783425a62e71f497 — Jeff a month ago 58f01ed
Improve nginx setup to include logs and better routing
2 files changed, 23 insertions(+), 7 deletions(-)

M Dockerfile
M nginx.conf
M Dockerfile => Dockerfile +4 -0
@@ 18,11 18,15 @@ RUN sh client/build.sh
# Run
FROM nginx:latest

RUN useradd jeffa.io-nginx

WORKDIR /jeffa.io/

COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=build-client /jeffa.io/client/build/ /jeffa.io/

RUN mkdir ./logs/

EXPOSE 9876:9876

CMD ["nginx", "-g", "daemon off;"]

M nginx.conf => nginx.conf +19 -7
@@ 1,10 1,23 @@
user jeffa.io-nginx;
error_log /jeffa.io/logs/error.log;
pid /jeffa.io/logs/nginx.pid;

events {}

http {
    include /etc/nginx/mime.types;
    keepalive_timeout 65;

    log_format main '$remote_addr - $remote_user [$time_local]  $status '
                    '"$request" $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
    access_log /jeffa.io/logs/access.log  main;

    server {
        listen 9876;
        server_name  jeffa.io;
        server_name jeffa.io;

        access_log /jeffa.io/logs/jeffa.io.access.log  main;

        gzip on;
        gzip_types text/css font/woff2 image/png;


@@ 15,22 28,21 @@ http {
        index  index.html index.htm;

        location / {
            autoindex on;
            try_files $uri $uri.html $uri/ 404;
            gzip_static on;

        }

        error_page  404              /404.txt;
        error_page  404 /404.txt;
        location /404.txt {
            add_header Content-Type text/plain;
            return 404;
            return 404 "404 - Resource not found. If this site sent you here, please let me know.";
        }

        error_page   500 502 503 504  /50x.txt;
        location /50x.txt {
            add_header Content-Type text/plain;
            return 500;
            return 500 "Internal server error.";
        }
    }
}

events {}