[blogs-web/fpm] Install and configure nginx



commit eac560e596d4bab7fa1f9a9163b7bbe736e697a2
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Mon Oct 12 15:26:49 2020 +0200

    Install and configure nginx

 Dockerfile |   3 ++
 nginx.conf | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+)
---
diff --git a/Dockerfile b/Dockerfile
index 7f6b6a9..3708be5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,6 +2,9 @@ FROM wordpress:fpm
 
 SHELL ["/bin/bash", "-c"]
     
+RUN apt-get update && apt-get install -y nginx-light
+ADD nginx.conf /etc/nginx/nginx.conf
+
 RUN apt-get update && apt-get install -y libldap-2.4-2 libldap2-dev && \
     docker-php-ext-configure ldap && \
     docker-php-ext-install -j$(nproc) ldap
diff --git a/nginx.conf b/nginx.conf
new file mode 100644
index 0000000..1cb74ce
--- /dev/null
+++ b/nginx.conf
@@ -0,0 +1,111 @@
+worker_processes  1;
+
+error_log  /dev/stderr warn;
+pid        /tmp/nginx.pid;
+
+events {
+    worker_connections  1024;
+}
+
+upstream php-fpm {
+    server localhost:9000;
+}
+
+map $uri $blogname {
+    ~^(?P<blogpath>/[_0-9a-zA-Z-]+/)files/(.*) $blogpath;
+}
+ 
+map $blogname $blogid {
+    default -999;
+    include /var/www/html/wp-content/uploads/nginx-helper/map.conf;
+}
+
+http {
+    proxy_temp_path /tmp/proxy_temp;
+    client_body_temp_path /tmp/client_temp;
+    fastcgi_temp_path /tmp/fastcgi_temp;
+    uwsgi_temp_path /tmp/uwsgi_temp;
+    scgi_temp_path /tmp/scgi_temp;
+
+    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  /dev/stdout  main;
+
+    sendfile        on;
+    #tcp_nopush     on;
+
+    keepalive_timeout  65;
+
+    #gzip  on;
+
+    server {
+        listen 8080 default_server;
+        listen [::]:8080 default_server;
+        
+        access_log /dev/stdout;
+        error_log /dev/stderr;
+        
+        absolute_redirect off;
+        
+        root /var/www/html;
+        index index.php;
+        
+        client_max_body_size 100M;
+    
+        location = /favicon.ico {
+            log_not_found off;
+            access_log off;
+        }
+    
+        location = /robots.txt {
+            allow all;
+            log_not_found off;
+            access_log off;
+        }
+    
+        location ~ ^(/[^/]+/)?files/(.+) {
+            try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
+            expires max;
+            access_log off;
+            log_not_found off;
+        }
+    
+        if (!-e $request_filename) {
+            rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
+            rewrite ^(/[^/]+)?(/wp-.*) $2 last;
+            rewrite ^(/[^/]+)?(/.*\.php) $2 last;
+        }
+    
+        # avoid php readfile()
+        location ^~ /blogs.dir {
+            internal;
+            alias /var/www/html/wp-content/blogs.dir;
+            access_log off;
+            log_not_found off;
+            expires max;
+        }
+    
+        location / {
+            try_files $uri $uri/ /index.php?$args;
+        }
+    
+        location ~ \.php$ {
+            include fastcgi_params;
+            fastcgi_intercept_errors on;
+            fastcgi_read_timeout 300;
+            fastcgi_param  HTTPS 'on';
+            fastcgi_pass php;
+            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
+        }
+    
+        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
+            expires max;
+            log_not_found off;
+        }
+    }
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]