From ac808f10c9011249da393284b4bc92903d604972 Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Mon, 3 Oct 2016 22:37:04 +0100 Subject: nginx documentation and configuration review --- tools/conf/etc/nginx/sites-enabled/default.conf | 49 ++++++++ tools/conf/etc/nginx/sites-enabled/mantisbt.conf | 23 ---- tools/conf/etc/nginx/sites/default.conf | 136 ++++++++++------------- tools/conf/etc/nginx/sites/drupal.conf | 8 +- tools/conf/etc/nginx/sites/flyspray.conf | 40 +++++++ tools/conf/etc/nginx/sites/laravel.conf | 10 +- tools/nginx.html | 90 +++++++++------ 7 files changed, 214 insertions(+), 142 deletions(-) create mode 100644 tools/conf/etc/nginx/sites-enabled/default.conf delete mode 100644 tools/conf/etc/nginx/sites-enabled/mantisbt.conf create mode 100644 tools/conf/etc/nginx/sites/flyspray.conf (limited to 'tools') diff --git a/tools/conf/etc/nginx/sites-enabled/default.conf b/tools/conf/etc/nginx/sites-enabled/default.conf new file mode 100644 index 0000000..4e01b88 --- /dev/null +++ b/tools/conf/etc/nginx/sites-enabled/default.conf @@ -0,0 +1,49 @@ + +server { + listen 443 ssl; + # listen [::]:443 ssl; + + server_name c9.core; + + root /srv/www/default; + + location /distfiles { + alias /usr/ports/distfiles; + } + + + location /bug { + index index.php; + alias /srv/www/default/flyspray; + try_files $uri $uri/ index.php$is_args$args; + } + + location ~ ^/bug(.+\.php)$ { ### This location block was the solution + alias /srv/www/default/flyspray; + + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + try_files $uri /index.php =404; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$1; + # fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass 127.0.0.1:9000; + } + + location / { + alias /srv/www/default/pmwiki/; + index pmwiki.php + try_files $uri $uri/ /pmwiki.php$is_args$args; + } + + location ~ \.php$ { + alias /srv/www/default/pmwiki; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index pmwiki.php; + try_files $uri /pmwiki.php =404; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass 127.0.0.1:9000; + } +} diff --git a/tools/conf/etc/nginx/sites-enabled/mantisbt.conf b/tools/conf/etc/nginx/sites-enabled/mantisbt.conf deleted file mode 100644 index 597983f..0000000 --- a/tools/conf/etc/nginx/sites-enabled/mantisbt.conf +++ /dev/null @@ -1,23 +0,0 @@ -server { - listen 443 ssl; - # listen [::]:443 ssl; - - root /srv/www/mantisbt; - server_name core.privat-network.net; - - index index.php; - - location / { - try_files $uri $uri/ /index.php$is_args$args; - } - - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_index index.php; - # try_files $uri /index.php =404; - include /etc/nginx/fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - # fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_pass 127.0.0.1:9000; - } -} diff --git a/tools/conf/etc/nginx/sites/default.conf b/tools/conf/etc/nginx/sites/default.conf index 95be0b7..1c71c44 100644 --- a/tools/conf/etc/nginx/sites/default.conf +++ b/tools/conf/etc/nginx/sites/default.conf @@ -1,82 +1,60 @@ server { - listen 80; - server_name localhost; - -#charset koi8-r; - - location / { - root html; - index index.html index.htm; - } - - error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - -# proxy the PHP scripts to Apache listening on 127.0.0.1:80 -# -#location ~ \.php$ { -# proxy_pass http://127.0.0.1; -#} - -# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 -# -#location ~ \.php$ { -# root html; -# fastcgi_pass 127.0.0.1:9000; -# fastcgi_index index.php; -# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; -# include fastcgi_params; -#} - -# deny access to .htaccess files, if Apache's document root -# concurs with nginx's one -# -#location ~ /\.ht { -# deny all; -#} + listen 443 ssl; + # listen [::]:443 ssl; + + server_name c9.core; + + root /srv/www/default; + + location /ports { + alias /var/ports/ports; + autoindex on; + } + + location /distfiles { + alias /var/ports/distfiles; + autoindex on; + } + + location /packages { + root /var/ports/packages; + autoindex off; + } + + + location /bug { + index index.php; + alias /srv/www/default/flyspray; + try_files $uri $uri/ index.php$is_args$args; + } + + location ~ ^/bug(.+\.php)$ { ### This location block was the solution + alias /srv/www/default/flyspray; + + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + try_files $uri /index.php =404; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$1; + # fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass 127.0.0.1:9000; + } + + location / { + alias /srv/www/default/pmwiki/; + index pmwiki.php + try_files $uri $uri/ /pmwiki.php$is_args$args; + } + + location ~ \.php$ { + alias /srv/www/default/pmwiki; + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index pmwiki.php; + try_files $uri /pmwiki.php =404; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass 127.0.0.1:9000; + } } - - -# another virtual host using mix of IP-, name-, and port-based configuration -# -#server { -# listen 8000; -# listen somename:8080; -# server_name somename alias another.alias; - -# location / { -# root html; -# index index.html index.htm; -# } -#} - - -# HTTPS server -# -#server { -# listen 443 ssl; -# server_name localhost; - -# ssl_certificate cert.pem; -# ssl_certificate_key cert.key; - -# ssl_session_cache shared:SSL:1m; -# ssl_session_timeout 5m; - -# ssl_ciphers HIGH:!aNULL:!MD5; -# ssl_prefer_server_ciphers on; - -# location / { -# root html; -# index index.html index.htm; -# } -#} - - diff --git a/tools/conf/etc/nginx/sites/drupal.conf b/tools/conf/etc/nginx/sites/drupal.conf index 39b096a..0407a6a 100644 --- a/tools/conf/etc/nginx/sites/drupal.conf +++ b/tools/conf/etc/nginx/sites/drupal.conf @@ -3,9 +3,9 @@ server { listen 192.168.1.254:443 ssl; listen 10.0.0.254:443 ssl; - server_name core.privat-network.net; + server_name c9.core - root /srv/www/drupal; ## <-- Your only path reference. + root /srv/www/default/drupal; ## <-- Your only path reference. # Enable compression, this will help if you have for instance advagg¿? module # by serving Gzip versions of the files. @@ -16,8 +16,8 @@ server { autoindex on; } - location /sysdoc { - alias /srv/www/sysdoc; + location /doc { + alias /srv/www/c9-doc; autoindex on; } diff --git a/tools/conf/etc/nginx/sites/flyspray.conf b/tools/conf/etc/nginx/sites/flyspray.conf new file mode 100644 index 0000000..80b5530 --- /dev/null +++ b/tools/conf/etc/nginx/sites/flyspray.conf @@ -0,0 +1,40 @@ + +server { + listen 443 ssl; + # listen [::]:443 ssl; + + server_name c9.core; + + root /srv/www/default/flyspray; + index index.php; + + location /ports { + alias /var/ports/ports; + autoindex on; + } + + location /distfiles { + alias /var/ports/distfiles; + autoindex on; + } + + location /packages { + root /var/ports/packages; + autoindex off; + } + + + location / { + try_files $uri $uri/ index.php$is_args$args; + } + + location ~ \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + try_files $uri /index.php =404; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_pass 127.0.0.1:9000; + } +} diff --git a/tools/conf/etc/nginx/sites/laravel.conf b/tools/conf/etc/nginx/sites/laravel.conf index f648f17..e563a3e 100644 --- a/tools/conf/etc/nginx/sites/laravel.conf +++ b/tools/conf/etc/nginx/sites/laravel.conf @@ -2,21 +2,21 @@ server { listen 443 ssl; # listen [::]:443 ssl; - root /srv/www/atom/public; - server_name core.privat-network.net; + root /srv/www/default/laravel/public; + server_name c9.core - location /sysdoc { - alias /srv/www/sysdoc; + location /c9-doc { + alias /srv/www/c9-doc; index index.html; autoindex on; } - index index.php; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { + index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; # try_files $uri /index.php =404; diff --git a/tools/nginx.html b/tools/nginx.html index 3daf8d5..0ded2b6 100644 --- a/tools/nginx.html +++ b/tools/nginx.html @@ -150,7 +150,7 @@ 1024 -

Example of http block with ssl configured;

+

Example of http block with ssl configured;

         #
@@ -228,14 +228,10 @@
 
 
         

4. Server with PHP

- -

Check /etc/nginx/sites - for more examples.

-

To debug configurations check logs and;

-        
+        nginx -V
         

4.1. Setup PHP

@@ -263,51 +259,83 @@

4.2. Setup Virtual Host

-

Server (virtual host) with Laravel, - /etc/nginx/sites/laravel.conf;

+

Server (virtual host) with pmwiki and flyspray, check + /etc/nginx/sites + for more examples. Install pmwiki and flyspray;

+ +
+        $ sudo prt-get depinst pmwiki flyspray
+        
+ +

This server is configured in a way that + root serves pmwiki and /tasks serves flyspray. In order to + flyspray to link correctly change index is needed;

         server {
             listen 443 ssl;
-            listen [::]:443 ssl;
+            # listen [::]:443 ssl;
 
-            root /srv/www/atom/public;
-            server_name core.privat-network.net;
-            index index.html index.htm index.php;
+            server_name c9.core;
 
-            charset utf-8;
+            root /srv/www/default;
 
-            location / {
-                try_files $uri $uri/ /index.php$is_args$args;
+            location /distfiles {
+                alias /usr/ports/distfiles;
             }
 
-            location = /favicon.ico { access_log off; log_not_found off; }
-            location = /robots.txt  { access_log off; log_not_found off; }
-
-            access_log off;
-            error_log  /var/log/nginx/core.privat-network.net-error.log error;
 
-            sendfile off;
+            location /tasks {
+                index index.php;
+                alias /srv/www/default/flyspray;
+                try_files $uri $uri/ index.php$is_args$args;
+            }
 
-            client_max_body_size 100m;
+            location ~  ^/tasks(.+\.php)$ {
+                alias /srv/www/default/flyspray;
 
-            location ~ \.php$ {
                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
-                fastcgi_pass 127.0.0.1:9000;
                 fastcgi_index index.php;
-                include fastcgi_params;
-                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
-                fastcgi_intercept_errors off;
-                fastcgi_buffer_size 16k;
-                fastcgi_buffers 4 16k;
+                try_files $uri /index.php =404;
+                include /etc/nginx/fastcgi_params;
+                fastcgi_param SCRIPT_FILENAME $document_root$1;
+                # fastcgi_pass unix:/var/run/php5-fpm.sock;
+                fastcgi_pass 127.0.0.1:9000;
+            }
+
+            location / {
+                alias /srv/www/default/pmwiki/;
+                index pmwiki.php
+                try_files $uri $uri/ /pmwiki.php$is_args$args;
             }
 
-            location ~ /\.ht {
-                deny all;
+            location ~ \.php$ {
+                alias /srv/www/default/pmwiki;
+                fastcgi_split_path_info ^(.+\.php)(/.+)$;
+                fastcgi_index pmwiki.php;
+                try_files $uri /pmwiki.php =404;
+                include /etc/nginx/fastcgi_params;
+                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+                # fastcgi_pass unix:/var/run/php5-fpm.sock;
+                fastcgi_pass 127.0.0.1:9000;
             }
         }
         
+

Change /srv/www/default/flyspray/index.php to;

+ +
+        <?php
+        /*
+           This is the main script that everything else is included
+           in.  Mostly what it does is check the user permissions
+           to see what they have access to.
+        */
+        define('IN_FS', true);
+        $_SERVER['SCRIPT_NAME'] = "/bug/index.php";
+        require_once(dirname(__FILE__).'/header.php');
+        
+

5. User Directory

Nginx Wiki UserDir

-- cgit 1.4.1-2-gfad0