From 5b50f0490b6f177cfabc5646c1786d1140598507 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Tue, 6 Feb 2018 02:40:27 -0500 Subject: Add sample nginx configuration I've recently been fighting my dev server to actually work with PHP. It seems like everytime I hop a system, or install nginx from scratch, something in my config is broken. So, I'm finally committing a 'working' (TM) baseline config to work off of when working with servers in the future. The idea is to add an Apache one at some point, too. --- srvs/nginx.conf | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 srvs/nginx.conf (limited to 'srvs/nginx.conf') diff --git a/srvs/nginx.conf b/srvs/nginx.conf new file mode 100644 index 0000000..a5e81f1 --- /dev/null +++ b/srvs/nginx.conf @@ -0,0 +1,81 @@ +## +# SCROTT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. +# +# For more information, please refer to UNLICENSE +## + +## +# This file is for configuring NGINX to work with Scrott. This is not +# a complete configuration, just a simple and genaric server {} block +# to use as a starting-point for setting up your server. +## + +server +{ + listen 80; + listen [::]:80 ipv6only=on; + listen 443 ssl; + listen [::]:443 ssl ipv6only=on; + + # set to your instance # + server_name localhost; + root /usr/share/nginx/scrott; + + index index.php; + keepalive_timeout 70; + + ## + # Completely deny access to user-supplied content. This content + # should instead be served by the df.php script, to enforce + # access permissions and prevent code-execution. + ## + location ^~ /dynmic + { + deny all; + return 404; + } + + ## + # Allow direct access to built-in static content, instead of + # passing these requests to the PHP system. + ## + location ^~ /static + { + try_files $uri $uri/ =404; + } + + ## + # Process normal requests via (clean) url rewriting. Unless + # the requested path exists on disk, pass it to index.php + # for processing. + ## + location / + { + rewrite ^(.*)$ /index.php$1; + } + + ## + # Hand-off completed php rewrites (or direct requests) to + # php-fpm for processing. + ## + location ~ [^/]\.php(/|$) + { + fastcgi_split_path_info ^((?U).+\.php)(.*)$; + + try_files $fastcgi_script_name =404; + + include fastcgi_params; + set $path_info $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $path_info; + + fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; + fastcgi_index index.php; + } +} -- cgit v1.2.3