Skip to content

Instantly share code, notes, and snippets.

@massimo-zaniboni
Created October 13, 2013 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save massimo-zaniboni/6964114 to your computer and use it in GitHub Desktop.
Save massimo-zaniboni/6964114 to your computer and use it in GitHub Desktop.
Nginx + PHP fastgci + Symfony1.X + SSL in a subfolder like www.domain-name.com/application-name/index.php
# NOTE:
# * substitute domain-name.com with the correct domain name
# * substitute application with the real name of the application
# * substitute application_directory with the real directory where it is installed the application
server {
listen 443 ssl;
server_name www.domain-name.com domain-name.com;
root /var/www/html;
keepalive_timeout 70;
ssl on;
ssl_certificate /etc/pki/tls/certs/calls-report.chained.crt;
# note: this is the chain of domain-name.com certificate, and parent certificate,
# exactly in this order, using "cat" utility
ssl_certificate_key /etc/pki/tls/private/domain-name.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
# jump to presentation page of www.domain-name.com
location = / {
root /var/www/html;
index index.html;
}
location = /index.html {
root /var/www/html;
}
#
# PHP Symfony 1.X application
#
location = /application {
rewrite ^ /application/index.php last;
}
location = /application/ {
index /application/index.php;
}
# execute PHP files of Voicity Asterisell application
location ~ ^/application/(index\.php)(/|$) {
root /var/www/application_directory/web;
rewrite ^/application(/.*)$ $1 break;
# try_files $uri =404;
fastcgi_split_path_info ^(/index\.php)(/.*)$;
# parse the $uri applying the regular expression.
# after this:
# - $fastcgi_script_name is the first match $1
# - $fastcgi_path_info is the second $2 match (the options)
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME /application$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param HTTPS "on";
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
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_pass 127.0.0.1:9000;
}
# download a static file
location /application/ {
root /var/www/application_directory/web;
rewrite ^/application(/.*)$ $1 break;
try_files $uri =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment