Last active
February 13, 2017 13:44
-
-
Save tinker1987/d7bc79203355bc14f397d0f010783455 to your computer and use it in GitHub Desktop.
Simple nginx vhost configuration with SSL for symfony project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
listen 80; | |
listen 443 ssl; | |
server_name {example.com}; | |
root /var/www/{path/to/project}; | |
client_max_body_size 64M; | |
## Generate SSL sertificates via next command | |
# sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt | |
ssl_certificate /etc/nginx/ssl/nginx.crt; | |
ssl_certificate_key /etc/nginx/ssl/nginx.key; | |
## | |
# Gzip Settings | |
## | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_comp_level 6; | |
gzip_min_length 1100; | |
gzip_buffers 16 8k; | |
gzip_proxied any; | |
gzip_http_version 1.1; | |
gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; | |
# ===== | |
proxy_buffers 8 64k; | |
proxy_buffer_size 128k; | |
fastcgi_buffers 8 64k; | |
fastcgi_buffer_size 128k; | |
location ~* \.(png|gif|jpg|jpeg|css|js|swf|ico|txt|xml|bmp|pdf|doc|docx|ppt|pptx|zip)$ { | |
access_log off; | |
expires 30d; | |
} | |
location / { | |
try_files $uri @rewriteapp; | |
} | |
location @rewriteapp { | |
rewrite ^(.*)$ /app.php/$1 last; | |
} | |
location ~ ^/(app|app_dev|config)\.php(/|$) { | |
fastcgi_pass unix:/run/php/php7.1-fpm.sock; #specify path to fpm.sock file | |
fastcgi_split_path_info ^(.+\.php)(/.*)$; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param HTTPS on; | |
fastcgi_param SYMFONY_ENV 'dev'; # set your symfony env here | |
} | |
error_log /var/log/nginx/{PROJECT_NAME}.error.log; | |
access_log /var/log/nginx/{PROJECT_NAME}.access.log; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.