diff --git a/container/nginx/compose.yml b/container/nginx/compose.yml new file mode 100644 index 0000000..73509a1 --- /dev/null +++ b/container/nginx/compose.yml @@ -0,0 +1,10 @@ +--- +services: + nginx: + image: docker.io/library/nginx:1.26.1-alpine3.19 + ports: + - "8080:80" + volumes: + - ./etc/nginx/conf.d:/etc/nginx/conf.d:ro + - ./etc/nginx/njs:/etc/nginx/njs:ro + - ./etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro diff --git a/container/nginx/etc/nginx/conf.d/default.conf b/container/nginx/etc/nginx/conf.d/default.conf new file mode 100644 index 0000000..e29193d --- /dev/null +++ b/container/nginx/etc/nginx/conf.d/default.conf @@ -0,0 +1,24 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + js_import utils.js; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location = /njs { + js_content utils.njsInfo; + } + + # 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; + } + +} \ No newline at end of file diff --git a/container/nginx/etc/nginx/nginx.conf b/container/nginx/etc/nginx/nginx.conf new file mode 100644 index 0000000..7686791 --- /dev/null +++ b/container/nginx/etc/nginx/nginx.conf @@ -0,0 +1,33 @@ +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + +load_module modules/ngx_http_js_module.so; + +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; + + js_path "/etc/nginx/njs/"; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/container/nginx/etc/nginx/njs/utils.js b/container/nginx/etc/nginx/njs/utils.js new file mode 100644 index 0000000..9b529a0 --- /dev/null +++ b/container/nginx/etc/nginx/njs/utils.js @@ -0,0 +1,6 @@ +function njsInfo(r) { + r.headersOut['content-type'] = 'text/javascript'; + r.return(200, JSON.stringify(njs)) +} + +export default {njsInfo} \ No newline at end of file