+13
Expanding NGINX Support
So far NGINX support in Ajenti is working, but it could use some expansion and some reordering.
First, I notice if you aren't very careful with the setup of your websites you can run into some hostnames loading other websites. This is because of how NGINX handles the request and looks for the server block to use.
My suggestion for a solution would be redesigning how Ajenti makes these config files and loads them. For example, when you create a website called "My Blog" it would create a config file for My Blog. Inside this config you can define the first server block, and the domains for it (myblog.com www.myblog.com). Then you define the content for this server block and the locations. Next maybe you want forums, but they need a slightly different configuration? You would define a new server block under My Blog with domains forum.myblog.com and forums.myblog.com and setup their content locations and parser. Now finally you want to add a special block for static content only. This block will not execute PHP. You add another server block under My Blog for static.myblog.com and setup its content location and define that PHP is not executed here no matter what.
Now you have your entire website setup, but what if you wanted to get more advanced with it? You can't, unless you do the following....
You create a new website called "My Computer Business" and define the first server block with domains (mycompbusiness.com www.mycompbusiness.com). You configure the content and locations and PHP etc. Now you want a catch all subdomain. The PHP script handles and directs the catch all, but if the catch all is not defined LAST in the list of servers, you will run into issues. You define *.mycompbusiness.com and set its location and PHP etc. You should be allowed to change the ORDER in which these server blocks are listed in the my-computer-business.conf file. You set your www.mycompbusiness.com and mycompbusiness.com first, then the catch all last. It will always fail over to the catch all when nothing else is met.
Also, global subdomains need to be able to be defined and loaded first. For example, I have webmail.* setup as a domain. This applies to ALL websites on the server and loads the webmail interface. This works, but only when it is defined first before any other wildcard subdomains. Using this I cannot define another wildcard subdomain because webmail.* needs to load first, then fail over to the wildcard subdomain, if it happens the other way around, things break. This needs to be able to be defined and then Ajenti should reject any subdomain being setup over a global wildcard such as webmail.mysite.com because webmail.* is defined, but this part is not required unless it is wanted.
The final example of something that is really needed would be ability to modify the NGINX config file, or at least change the variables you have set as defaults on a page somewhere. There should be a master NGINX setup page we can modify, and then a box for additional variables to define, and then an advanced page that we can just modify the whole NGINX.conf file without Ajenti injecting its own code (A check box to enable this would disable the previous pages and only allow modifications here).
I'm aware this would require a rewrite of the NGINX support, but it would make NGINX configuration on Ajenti go MUCH smoother with a higher level of customization available without having to dump the module all together to achieve more advanced configurations. Also, an option to just paste a websites configuration file 100% would be great also. A check box that disables Ajenti handling a websites config file and uses whatever you put into a box.
I can expand on this or add better examples if requested. Thank you!
Sources: http://nginx.org/en/docs/http/request_processing.html : http://nginx.org/en/docs/http/server_names.html
First, I notice if you aren't very careful with the setup of your websites you can run into some hostnames loading other websites. This is because of how NGINX handles the request and looks for the server block to use.
My suggestion for a solution would be redesigning how Ajenti makes these config files and loads them. For example, when you create a website called "My Blog" it would create a config file for My Blog. Inside this config you can define the first server block, and the domains for it (myblog.com www.myblog.com). Then you define the content for this server block and the locations. Next maybe you want forums, but they need a slightly different configuration? You would define a new server block under My Blog with domains forum.myblog.com and forums.myblog.com and setup their content locations and parser. Now finally you want to add a special block for static content only. This block will not execute PHP. You add another server block under My Blog for static.myblog.com and setup its content location and define that PHP is not executed here no matter what.
Now you have your entire website setup, but what if you wanted to get more advanced with it? You can't, unless you do the following....
You create a new website called "My Computer Business" and define the first server block with domains (mycompbusiness.com www.mycompbusiness.com). You configure the content and locations and PHP etc. Now you want a catch all subdomain. The PHP script handles and directs the catch all, but if the catch all is not defined LAST in the list of servers, you will run into issues. You define *.mycompbusiness.com and set its location and PHP etc. You should be allowed to change the ORDER in which these server blocks are listed in the my-computer-business.conf file. You set your www.mycompbusiness.com and mycompbusiness.com first, then the catch all last. It will always fail over to the catch all when nothing else is met.
Also, global subdomains need to be able to be defined and loaded first. For example, I have webmail.* setup as a domain. This applies to ALL websites on the server and loads the webmail interface. This works, but only when it is defined first before any other wildcard subdomains. Using this I cannot define another wildcard subdomain because webmail.* needs to load first, then fail over to the wildcard subdomain, if it happens the other way around, things break. This needs to be able to be defined and then Ajenti should reject any subdomain being setup over a global wildcard such as webmail.mysite.com because webmail.* is defined, but this part is not required unless it is wanted.
The final example of something that is really needed would be ability to modify the NGINX config file, or at least change the variables you have set as defaults on a page somewhere. There should be a master NGINX setup page we can modify, and then a box for additional variables to define, and then an advanced page that we can just modify the whole NGINX.conf file without Ajenti injecting its own code (A check box to enable this would disable the previous pages and only allow modifications here).
I'm aware this would require a rewrite of the NGINX support, but it would make NGINX configuration on Ajenti go MUCH smoother with a higher level of customization available without having to dump the module all together to achieve more advanced configurations. Also, an option to just paste a websites configuration file 100% would be great also. A check box that disables Ajenti handling a websites config file and uses whatever you put into a box.
I can expand on this or add better examples if requested. Thank you!
Sources: http://nginx.org/en/docs/http/request_processing.html : http://nginx.org/en/docs/http/server_names.html
Customer support service by UserEcho