Skip to content

Instantly share code, notes, and snippets.

@smarteist
Created August 1, 2023 16:56
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 smarteist/d0d8a22653514c0c3ec11cde0b84b6c9 to your computer and use it in GitHub Desktop.
Save smarteist/d0d8a22653514c0c3ec11cde0b84b6c9 to your computer and use it in GitHub Desktop.
nginx confings for symfony2
# -------------------
# SYMFONY CONF
# -------------------
server {
listen 443 ssl http2;
listen 80;
server_name domain.com www.domain.com;
charset utf-8;
root "/var/www/domain/public_html";
gzip off;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
# Force HTTPS connection. This rules is domain agnostic
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
# 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 unix:/var/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS on;
}
location ~* ^.+.(js|css|png|jpg|jpeg|gif|bmp|rtf|ico|html|xml|woff|woff2|ttf|svg|svgz|eot|otf|rss|zip|rar|bz2|wav|mp4|mp3|ogg)$ {
add_header Access-Control-Allow-Origin *;
access_log off;
log_not_found off;
expires 365d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment