Open sinasalek opened 8 years ago
I just installed virtualmin nginx module according to https://www.virtualmin.com/documentation/web/nginx With a quick comparison, there are some important features the it offers comparing to this module :
Initially I planned to create module that only manages FPM. But lurking through the core Nginx module code revealed that adding new PHP execution mode will require it's modification. So I created module that manages both Nginx and FPM configs for domains. For now it fits my needs completely, however there's always room for improvements. So let's see:
Thanks for the quick response.
2 and 3 need investigation.
In addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER['DOCUMENT_ROOT']). In case the PHP file is outside the document root, only its directory is scanned. Only INI settings with the modes PHP_INI_PERDIR and PHP_INI_USER will be recognized in .user.ini-style INI files.
Discussion goes nowhere, let's talk about what you really need.
What settings you really need to be defined?
Well what i need is to let the user modify php settings per virtualhost via UI the way the he can when apache or nginx module is used
Well if we talk about this http://php.net/manual/en/configuration.file.per-user.php, then this typo of files can be easily created and modified through built in filemanager :D I never used this option, so if we wanna provide interface for such tasks then it requires some more investigation and some time to develop :)))
Sure it does, just wanted to put it out there in case you were interested :)
Yep, making module better is a good thing :) I'll see what can be done to add feature you request. Any particular settings are required now? Would be a great opportunity to start adding and testing :)
Thanks, that would be great :) I'm setting up two new servers using your module, both require modification of generated nginx config for the web applications to work properly, since there is no way to do it in a non hackish way using the module. I've mentioned this on another issue earlier as you know. I think this is probably the most important feature that many will need including myself. I'll send more feedback if i encounter any major limitation.
What CMS you use for your two servers? Did you try default config?
One of the applications is a custom frameworks that required lots of custom configs. No way to make it generic :). The others are Moodle and Magento, the default config works just fine but they both had some additional customization in their .htaccess that needed to be ported to nginx. Check this out :
# bad request
error_page 400 = /errorDocuments/badRequest.html;
# Authorization Required
error_page 401 = /errorDocuments/authorizationRequired.html;
# access forbidden
error_page 403 = /errorDocuments/accessForbidden.html;
# document not found
error_page 404 = /errorDocuments/pageNotFound.html;
# internal server error
error_page 500 = /errorDocuments/maintenance.html;
# enable gzip compression
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain text/xml text/css application/x-javascript application/xml application/xhtml+xml application/rss+xml application/javascript;
gzip_proxied no-cache no-store private expired auth;
gzip_vary on;
# end gzip configuration
autoindex on;
# (Begin) Protect files and directories from prying eyes.
location ~ \.(test|sql|bak)$|^(development|documents|old|garbage|docs|test|delete)$ {
deny all;
}
# (End) Protect files and directories from prying eyes.
location ~ \.(js|css|png|jpg|jpeg|gif|ico|html|woff|ttf|svg|eot|otf)$ {
valid_referers none blocked ~.facebook. ~.google. ~.fb. ~.friendfeed. ~.yahoo. ~.bing. ~.feedreader. ~.feedly. server_names ~($host);
if ($invalid_referer) {
rewrite .*\.(jpe?g|bmp|png)$ /hotlink.gif redirect;
}
add_header "Access-Control-Allow-Origin" "*";
expires 1M;
access_log off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
gzip_static on;
proxy_hide_header Set-Cookie;
proxy_ignore_headers Set-Cookie;
# important! Remember the special inheritance rules for proxy_set_header:
# http://nginx.org/ru/docs/http/ngx_http_proxy_module.html#proxy_set_header
proxy_set_header Cookie "";
fastcgi_param PHP_VALUE "session.use_cookies=0";
fastcgi_hide_header Set-Cookie;
}
# stop hotlink loop
location = /hotlink.gif { }
# BEGIN REQUIRED FOR WEBFONTS AND static file cache
index index.php index.html index.htm;
location /forum {
rewrite ^(.*)$ http://forum.example.com redirect;
}
location /favicon { rewrite ^/favicon\.ico$ /view/themes/default/images/favicon.ico break; }
location /sitemap { rewrite ^/sitemap\.xml$ /view/model/sitemap.xml.php break; }
location /robots { rewrite ^/robots\.txt /view/model/robots.txt break; }
location /rss { rewrite ^(.*)$ /view/model/rss.php?mode=full break; }
location cache { }
location ~ ^/(.*/)?files\/printablePhotos\/*/ { return 403; }
#--(Begin)-- Redirect old paths
location /form { rewrite ^/form/(.+)$ /files/extform/$1 redirect; }
#--(End)-- Redirect old paths
location / {
rewrite /(files/blogSystem/.*)$ http://blogs.example.com/$1 redirect;
# This is cool because no php is touched for static content
try_files $uri @rewrite;
}
location @rewrite {
if ($http_host ~ "^class\.example\.com$"){ rewrite ^/tweet(.*)$ /twitter/class$1 last; }
if ($http_host ~ "^class\.example\.com$"){ rewrite ^/$ /sn/siteStaticPages/id/3 last; }
if ($http_host !~ "class\.example\.com"){ rewrite ^/sn/siteStaticPages/id/3$ http://class.example.com redirect; }
if ($http_host ~ "^print\.example\.com$"){ rewrite ^/$ /sn/printLandingPage last; }
rewrite .*news/archives/(.*)$ http://newsarchive.example.com/news/archives/$1 redirect;
rewrite (news/[^/]+)/full$ /$1 redirect;
rewrite ((news|articles)/[^/]+)/$ /$1 redirect;
rewrite ^/panel/cn/([^/]*)?(.*)$ /panel/model/$1.php?qs=$2& last;
rewrite ^/panel/?(.*)$ /panel/index.php?qs=$1 last;
rewrite ^/cn/([^/]*)?(.*)$ /model/$1.php?qs=$2& last;
rewrite ^/(.*)$ /index.php?qs=$1;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri =404;
include nginx.fastcgi.conf;
fastcgi_pass php_farm;
}
As far as I can see theese are configs ready to be used by Nginx.
I just got some interesting idea: what if I add some textarea in Virtualmin domain management, that is inserted inside the Nginx config server
block later?
So user will be able to add some additional settings to already existing config. Just a quick solution that might work.
Yes that would be a very good quick solution.
I check the source code of the module, and it seems that you have started almost from scratch. So i was wondering why you haven't used source code of nginx-webmin module or Apache module. https://github.com/vixh/nginx-webmin https://github.com/lewellyn/virtualmin-nginx