From 305636eae7f0a870d19dc47e97d41710ad22d731 Mon Sep 17 00:00:00 2001 From: Magicalex Date: Mon, 29 Oct 2018 20:58:21 +0000 Subject: [PATCH] add(): custom flarum vhost (#29) --- Dockerfile | 2 +- README.md | 11 ++++++++--- .../etc/nginx/conf.d/custom-vhost-flarum.conf | 6 ++++++ rootfs/etc/nginx/nginx.conf | 19 +++++++++---------- 4 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 rootfs/etc/nginx/conf.d/custom-vhost-flarum.conf diff --git a/Dockerfile b/Dockerfile index 50f11ce..78f1af3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,6 @@ RUN echo "@community https://nl.alpinelinux.org/alpine/v3.8/community" >> /etc/a COPY rootfs / RUN chmod +x /usr/local/bin/* /services/*/run /services/.s6-svscan/* -VOLUME /flarum/app/assets /flarum/app/extensions +VOLUME /flarum/app/assets /flarum/app/extensions /etc/nginx/conf.d EXPOSE 8888 CMD ["run.sh"] diff --git a/README.md b/README.md index 235365a..69a2f25 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ### What is this ? -Flarum is the next-generation forum software that makes online discussion fun. It's simple, fast, and free. http://flarum.org/ +Simple forum software for building great communities. http://flarum.org/ ### Features @@ -26,6 +26,7 @@ Flarum is the next-generation forum software that makes online discussion fun. I - **/flarum/app/assets** : Flarum assets directory - **/flarum/app/extensions** : Flarum extension directory +- **/etc/nginx/conf.d** : Nginx location directory ### Environment variables @@ -72,6 +73,7 @@ services: volumes: - /mnt/docker/flarum/assets:/flarum/app/assets - /mnt/docker/flarum/extensions:/flarum/app/extensions + - /mnt/docker/flarum/nginx:/etc/nginx/conf.d depends_on: - mariadb @@ -159,6 +161,11 @@ touch 403.html 404.html 500.html 503.html chown -R 991:991 /mnt/docker/flarum ``` +### Custom vhost flarum nginx + +File to change the vhost flarum `/etc/nginx/conf.d/custom-vhost-flarum.conf` +To use file custom-vhost-flarum.conf add volume `/etc/nginx/conf.d` + ### Custom composer repositories To use the composer repository system, add your repo name and json representation in `/mnt/docker/flarum/extensions/composer.repositories.txt` : @@ -169,5 +176,3 @@ my_public_repo|{"type":"vcs","url":"https://github.com/my/repo"} ``` https://getcomposer.org/doc/03-cli.md#modifying-repositories - - diff --git a/rootfs/etc/nginx/conf.d/custom-vhost-flarum.conf b/rootfs/etc/nginx/conf.d/custom-vhost-flarum.conf new file mode 100644 index 0000000..776c9dc --- /dev/null +++ b/rootfs/etc/nginx/conf.d/custom-vhost-flarum.conf @@ -0,0 +1,6 @@ +# Example: + +# fix for flagrow/sitemap (https://github.com/flagrow/sitemap) +# location = /sitemap.xml { +# try_files $uri $uri/ /index.php?$query_string; +# } diff --git a/rootfs/etc/nginx/nginx.conf b/rootfs/etc/nginx/nginx.conf index c9347d7..3ae33b4 100644 --- a/rootfs/etc/nginx/nginx.conf +++ b/rootfs/etc/nginx/nginx.conf @@ -67,18 +67,15 @@ http { error_page 500 /500.html; error_page 503 /503.html; - location = /403.html { root /flarum/app/vendor/flarum/core/error; } - location = /404.html { root /flarum/app/vendor/flarum/core/error; } - location = /500.html { root /flarum/app/vendor/flarum/core/error; } - location = /503.html { root /flarum/app/vendor/flarum/core/error; } + location = /403.html { alias /flarum/app/vendor/flarum/core/error; } + location = /404.html { alias /flarum/app/vendor/flarum/core/error; } + location = /500.html { alias /flarum/app/vendor/flarum/core/error; } + location = /503.html { alias /flarum/app/vendor/flarum/core/error; } location / { try_files $uri $uri/ /index.php?$query_string; } location /api { try_files $uri $uri/ /api.php?$query_string; } location /admin { try_files $uri $uri/ /admin.php?$query_string; } - # fix for flagrow/sitemap (https://github.com/flagrow/sitemap) - location = /sitemap.xml { try_files $uri $uri/ /index.php?$query_string; } - # Access path list # -------------------------------------- location ~ /\. { @@ -125,16 +122,18 @@ http { try_files $uri =404; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.*)$; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param HTTP_PROXY ""; fastcgi_index index.php; fastcgi_pass unix:/tmp/php-fpm.sock; fastcgi_intercept_errors on; fastcgi_request_buffering off; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param HTTP_PROXY ""; fastcgi_param REMOTE_ADDR $http_x_real_ip; } + include /etc/nginx/conf.d/custom-flarum.conf + } }