Commit 11d5681b authored by Owain Jones's avatar Owain Jones
Browse files

simplified nginx configs and allow access to dev tools via server IP

parent a792835e
server {
listen 80;
server_name apc.dev.*;
root /home/gliders/code/APC-Admin;
error_log /var/log/nginx/apc.error.log;
access_log /var/log/nginx/apc.access.log;
location / {
try_files $uri @apc;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location @apc {
fastcgi_pass phpfcgi;
fastcgi_index index.php;
fastcgi_buffers 256 4k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME index.php;
fastcgi_param HTTPS off;
}
}
......@@ -25,12 +25,19 @@ ln -s /home/gliders/bin/composer.phar /home/gliders/bin/composer
# Set up python environment and directories
mkdir -p /home/gliders/code
mkdir -p /home/gliders/devtools
mkdir -p /home/gliders/pythonenv
mkdir -p /var/gliders/www /var/gliders/www_dev /var/gliders/logs
virtualenv /home/gliders/pythonenv --system-site-packages
echo 'source /home/gliders/pythonenv/bin/activate' >> /home/gliders/.bash_profile
source /home/gliders/pythonenv/bin/activate
# Set up our web dev tools dirs...
ln -s /usr/share/phpMyAdmin /home/gliders/devtools/phpma
# PHPCI and APC-Admin would be useful, but as we don't need
# them for the production server they're left out of this
# script.
cd /home/gliders/code
# Add contents of /home/gliders/.ssh/id_rsa.pub to GitLab, then:
git clone git@gitlab.noc.soton.ac.uk:owanes/gliders-tools.git
......@@ -81,4 +88,4 @@ export BOWERPHP_TOKEN=$GITHUB_API_KEY
# Deploy the website
cd /home/gliders/code/gliders-website
sh bin/deploy.sh /var/gliders/www_dev dev
sh bin/deploy.sh /var/gliders/www prod
\ No newline at end of file
sh bin/deploy.sh /var/gliders/www prod
server {
listen 80 default_server;
root /home/gliders/devtools/;
location / {
auth_basic "Restricted";
auth_basic_user_file /home/gliders/devtools/.htpasswd;
index index.php index.xhtml index.html index.htm index.txt;
autoindex on;
}
location /phpci {
index index.php;
try_files $uri /phpci/public/index.php$is_args$args;
}
error_log /var/log/nginx/devtools.error.log;
access_log off;
location ~ \.php {
fastcgi_index index.php;
fastcgi_pass hhvmfcgi;
fastcgi_buffers 256 4k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
server {
listen 80;
server_name es.dev.*;
location / {
proxy_pass http://127.0.0.1:9200;
}
}
......@@ -6,24 +6,26 @@
limit_req_zone $binary_remote_addr zone=gliders:10m rate=10r/s;
map $host $symfony_root {
# default /home/gliders/code/gliders-website;
default /var/gliders/www;
}
server {
listen 80;
map $host $symfony_root_dev {
default /var/gliders/www_dev;
}
server_name ~^((?<symfonyenv>.+)\.)?gliders.*$;
server {
listen 80 default_server;
if ($symfonyenv) {
set $symfonyfile "app_$symfonyenv";
set $symfonyroot "/var/gliders/www_$symfonyenv";
}
server_name _ gliders.*;
if ($symfonyenv = "") {
set $symfonyfile "app";
set $symfonyroot "/var/gliders/www";
set $symfonyenv "prod";
}
root $symfony_root/web;
root $symfonyroot/web;
error_log /var/log/nginx/gliders.error.log;
access_log /var/log/nginx/gliders.access.log;
access_log /var/log/nginx/$symfonyenv.gliders.access.log;
# Enable compression. Very helpful when we're getting stuff like
# large amounts of vehicle tracks in JSON form!
......@@ -31,11 +33,11 @@ server {
gzip_types text/plain application/xml text/html text/css application/json application/x-javascript text/xml text/javascript;
# strip app.php/ prefix if it is present
rewrite ^/app\.php/?(.*)$ /$1 permanent;
rewrite ^/$symfonyfile\.php/?(.*)$ /$1 permanent;
location / {
limit_req zone=gliders burst=5;
set $index_file app.php;
set $index_file $symfonyfile".php";
if (-f $document_root/.maintenance) {
return 503;
}
......@@ -75,7 +77,7 @@ server {
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
rewrite ^(.*)$ /${symfonyfile}.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
......@@ -83,81 +85,7 @@ server {
fastcgi_pass hhvmfcgi;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $symfony_root/web$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $symfonyroot/web$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
server {
listen 80;
server_name dev.gliders.*;
root $symfony_root_dev/web;
error_log /var/log/nginx/dev.gliders.error.log;
access_log /var/log/nginx/dev.gliders.access.log;
# Enable compression. Very helpful when we're getting stuff like
# large amounts of vehicle tracks in JSON form!
gzip on;
gzip_types text/plain application/xml text/html text/css application/json application/x-javascript text/xml text/javascript;
# strip app.php/ prefix if it is present
rewrite ^/app_dev\.php/?(.*)$ /$1 permanent;
location / {
limit_req zone=gliders burst=5;
set $index_file app.php;
if (-f $document_root/.maintenance) {
return 503;
}
index $index_file;
try_files $uri @rewriteapp;
}
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maintenance.html break;
}
location ~ ^/(images|fonts|css|js) {
access_log off;
error_log off;
try_files $uri =404;
expires 1y;
add_header Cache-Control "public";
}
location ~ ^/images/vehicles/(?<vehicle_type>[a-zA-Z0-9]+)_(?<vehicle_name>[a-zA-Z0-9]+)\.(png|jpg)$ {
access_log off;
error_log off;
try_files $uri images/vehicles/$vehicle_type.png =404;
}
location /static/logs {
alias /var/gliders/logs;
}
location /var/gliders/logs {
alias /var/gliders/logs;
}
location /static {
alias /var/gliders/static;
}
location @rewriteapp {
rewrite ^(.*)$ /app_dev.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass phpfcgi;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $symfony_root_dev/web$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
server {
listen 80;
server_name hhvm.dev.*;
location / {
fastcgi_pass 127.0.0.1:9001;
include fastcgi_params;
}
}
# https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/
# NOTE: This makes any .php file other than app, app_dev and config.php
# downloadable. If you want one to run, add it to the "pass the PHP scripts to
# upstream FCGI" location section below. Be careful adding PHP files with
# sensitive data like passwords inside them.
server {
listen 80;
server_name phpci.dev.*;
root /home/gliders/code/phpci/public;
error_log /var/log/nginx/phpci.error.log;
access_log /var/log/nginx/phpci.access.log;
location / {
try_files $uri @phpci;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location @phpci {
fastcgi_pass phpfcgi;
fastcgi_index index.php;
fastcgi_buffers 256 4k;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param SCRIPT_NAME index.php;
fastcgi_param HTTPS off;
}
}
# We don't yet have an SSL cert (not like a VM on my own machine needs one...)
# server {
# listen 443;
#
# server_name gliders.vm *.gliders.vm;
# root /home/gliders/code/gliders-website/web;
#
# ssl on;
# ssl_certificate /etc/ssl/certs/symfony2.crt;
# ssl_certificate_key /etc/ssl/private/symfony2.key;
#
# error_log /var/log/nginx/symfony2.error.log;
# access_log /var/log/nginx/symfony2.access.log;
#
# # strip app.php/ prefix if it is present
# rewrite ^/app\.php/?(.*)$ /$1 permanent;
#
# location / {
# index app.php;
# try_files $uri @rewriteapp;
# }
#
# location @rewriteapp {
# rewrite ^(.*)$ /app.php/$1 last;
# }
#
# # pass the PHP scripts to FastCGI server from upstream phpfcgi
# location ~ ^/(app|app_dev|config)\.php(/|$) {
# fastcgi_pass phpfcgi;
# fastcgi_split_path_info ^(.+\.php)(/.*)$;
# include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param HTTPS on;
# }
# }
# Configuration for phpMyAdmin -- set it up to use php-fpm etc.
server {
listen 80;
# root /home/gliders/phpma;
root /usr/share/phpMyAdmin;
index index.php index.html index.htm;
server_name phpma.dev.*; # update with actual hostname when we get it
location / {
try_files $uri $uri/ /index.php;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
# Serve static files directly
location ~* \.(png|jpe?g|gif|ico)$ {
expires 1y;
access_log off;
try_files $uri $uri/ @rewrite;
gzip off;
}
location ~* \.(css|js)$ {
expires 1d;
access_log off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment