Submitted by vstoykov on Mon, 02/20/2017 - 09:10
By embracing this convention it will be more difficult to make things go wrong when editing nginx.conf (for example, see this bug: Adding virtual server to Nginx not working correctly).
It's a widespread meme to store configuration files of the virtual servers to the /etc/nginx/sites-available
directory and to create symlinks into /etc/nginx/sites-enabled/
pointed to the corresponding virtual server's configuration file.
include /etc/nginx/sites-enabled/*;
Status:
Active
Comments
Submitted by vstoykov on Mon, 02/20/2017 - 09:11 Comment #1
Submitted by JamieCameron on Tue, 02/21/2017 - 22:58 Comment #2
Virtualmin already supports this config format, and will use it by default on Debian-based systems.
Elsewhere, you can control which file or directory new Nginx config files are added to at System Settings -> Features and Plugins -> Config (in the Nginx row).
Submitted by Kintaro on Thu, 02/23/2017 - 09:01 Comment #3
I'm on Debian 8 and I confirm that virtualmin is already acting like said by Jamie.
Submitted by vstoykov on Thu, 02/23/2017 - 11:56 Comment #4
Not working as intended. After I added
server3.test
this happened:[root@testserver123 nginx]# grep available nginx.conf
[root@testserver123 nginx]# grep enabled nginx.conf
# Settings for a TLS enabled server.
[root@testserver123 nginx]# cat sites-available
server {
server_name server3.test www.server3.test;
listen 192.168.100.42;
root /home/server3/public_html;
index index.html index.htm index.php;
access_log /var/log/virtualmin/server3.test_access_log;
error_log /var/log/virtualmin/server3.test_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/server3/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/server3/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/php-nginx/14878721112469.sock/socket;
}
listen 192.168.100.42:443 ssl;
ssl_certificate /home/server3/ssl.cert;
ssl_certificate_key /home/server3/ssl.key;
}
[root@testserver123 nginx]#
This is after I changed the settings in System Settings -> Features and Plugins -> Config (in the Nginx row).
Submitted by vstoykov on Thu, 02/23/2017 - 12:04 Comment #5
I removed all servers, removed the sites-available file and created directories:
[root@testserver123 nginx]# mkdir sites-available
[root@testserver123 nginx]# mkdir sites-enabled
Then created a new server
testingvirtualmin.test
.This time it writes it correctly:
[root@testserver123 nginx]# ls sites-enabled/ -l
total 0
lrwxrwxrwx 1 root root 54 Feb 23 12:59 testingvirtualmin.test.conf -> /etc/nginx/sites-available/testingvirtualmin.test.conf
[root@testserver123 nginx]# ls sites-available/
testingvirtualmin.test.conf
But it did not added
include /etc/nginx/sites-enabled/*;
line within nginx.conf:[root@testserver123 nginx]# grep enabled nginx.conf
# Settings for a TLS enabled server.
[root@testserver123 nginx]#
Submitted by vstoykov on Thu, 02/23/2017 - 12:13 Comment #6
Using
sites-enabled
(directory where symlinks are created) is pointless, because Virtualmin is disabling sites by adding:location ~ /.* {
root /home/example2/public_html;
rewrite ^/.* /disabled_by_virtualmin.html break;
}
instead of removing the symlink.
Submitted by vstoykov on Thu, 02/23/2017 - 12:17 Comment #7
After removing a virtual server there is a file ".lock" with a number:
[root@testserver123 nginx]# cat sites-available/example2.test.conf.lock 6011 [root@testserver123 nginx]#
Submitted by JamieCameron on Thu, 02/23/2017 - 22:38 Comment #10
Virtualmin assumes that the correct
include
line already exists - it won't add it for you.This is because on Debian and Ubuntu systems that use this config format by default, the primary Nginx config already has such an
include
line.