From a7e012c46070f318cad2f92193660953e0c8d4f6 Mon Sep 17 00:00:00 2001 From: christiangoeschel Date: Thu, 25 Jul 2024 03:03:19 +0000 Subject: [PATCH] update --- Dockerfile | 28 ++++++++++++++++++-- docker-compose.yml | 29 ++++++++++++++++++++ nginx/default-nginx-proxy.conf | 48 ++++++++++++++++++++++++++++++++++ nginx/default-nginx-web.conf | 45 +++++++++++++++++++++++++++++++ nginx/default.conf | 45 +++++++++++++++++++++++++++++++ nginx/nginx.conf | 32 +++++++++++++++++++++++ 6 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 docker-compose.yml create mode 100644 nginx/default-nginx-proxy.conf create mode 100644 nginx/default-nginx-web.conf create mode 100644 nginx/default.conf create mode 100644 nginx/nginx.conf diff --git a/Dockerfile b/Dockerfile index 3bd8406..3ad4520 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,26 @@ -FROM nginx:latest -COPY ./ /usr/share/nginx/html +FROM alpine@sha256:0a4eaa0eecf5f8c050e5bba433f58c052be7587ee8af3e8b3910ef9ab5fbe9f5 AS base +LABEL maintainer="Christian Goeschel Ndjomouo" +RUN apk update +RUN apk add nginx +RUN adduser -D -g 'www' www +RUN mkdir /www +RUN chown -R www:www /var/lib/nginx +RUN chown -R www:www /www +COPY index.html /www/index.html + +WORKDIR /etc/nginx/ +COPY nginx/nginx.conf nginx.conf +RUN mkdir conf.d/ +WORKDIR / + +FROM base AS portfolio-proxy +WORKDIR /etc/nginx/conf.d/ +COPY nginx/default-nginx-proxy.conf default.conf +EXPOSE 80/tcp +CMD ["nginx","-g","daemon off;"] + +FROM base AS portfolio-web +WORKDIR /etc/nginx/conf.d/ +COPY nginx/default-nginx-web.conf default.conf +EXPOSE 8080/tcp +CMD ["nginx","-g","daemon off;"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..ba89d06 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,29 @@ +name: myportfolio +services: + proxy: + build: + context: . + dockerfile: Dockerfile + target: portfolio-proxy + ports: + - name: proxy-port + target: 80 + published: "80" + protocol: tcp + app_protocol: http + mode: host + + web: + build: + context: . + dockerfile: Dockerfile + target: portfolio-web + expose: + - "8080/tcp" + volumes: + - portfolio-www:/www +volumes: + portfolio-www: + external: true + name: portfolio-www + diff --git a/nginx/default-nginx-proxy.conf b/nginx/default-nginx-proxy.conf new file mode 100644 index 0000000..baface8 --- /dev/null +++ b/nginx/default-nginx-proxy.conf @@ -0,0 +1,48 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + proxy_buffering on; + proxy_buffers 16 4k; + proxy_buffer_size 4k; + proxy_busy_buffers_size 8k; + proxy_pass http://myportfolio-web-1:8080; + } + + #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; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} + diff --git a/nginx/default-nginx-web.conf b/nginx/default-nginx-web.conf new file mode 100644 index 0000000..51e1b42 --- /dev/null +++ b/nginx/default-nginx-web.conf @@ -0,0 +1,45 @@ +server { + listen 8080; + listen [::]:8080; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /www; + index index.html index.htm; + } + + #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; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} + diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..ac54d8e --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,45 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + #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; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} + diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..f966dd4 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,32 @@ + +user www; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +}