Skip to content

Instantly share code, notes, and snippets.

@soerenmartius
Created June 10, 2015 13:27
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 soerenmartius/2a7860dab2a8cabfdacb to your computer and use it in GitHub Desktop.
Save soerenmartius/2a7860dab2a8cabfdacb to your computer and use it in GitHub Desktop.
Shopware 5 Nginx Host
server {
listen 80;
server_name www.yourhost.de dev.yourhost.de;
root /var/www/vhosts/dev.duschdichtungen-shop.de/htdocs;
error_log /var/log/nginx/yourhost_error.log;
access_log /var/log/nginx/yourhost_access.log;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /templates/_default/backend/_resources/resources/css/icon-set.css {
gzip off;
}
## Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
## Deny all attems to access possible configuration files
location ~ \.(tpl|yml|ini|log)$ {
deny all;
}
## Deny access to media upload folder
location ^~ /media/temp/ {
deny all;
}
location ^~ /cache/ {
deny all;
}
location ^~ /files/documents/ {
deny all;
}
# Block direct access to ESDs, but allow the follwing download options:
# * 'PHP' (slow)
# * 'X-Accel' (optimized)
# Also see http://wiki.shopware.com/ESD_detail_1116.html#Ab_Shopware_4.2.2
location ^~ /files/552211cce724117c3178e3d22bec532ec/ {
internal;
}
# Breaks backend/media/ rewrite
#
#location ~ /(engine|files|templates|media)/ {
# location ~ \.php$ {
# return 403;
# }
#}
# Shopware install / update
location /recovery/install {
index index.php;
try_files $uri /recovery/install/index.php?$args;
}
location /recovery/update {
index index.php;
try_files $uri /recovery/update/index.php?$args;
}
location / {
location ~* "^/themes/Frontend/Responsive/frontend/_public/vendors/fonts/open-sans-fontface/(?:.+)\.(?:ttf|eot|svg|woff)$" {
expires max;
add_header Cache-Control "public";
access_log off;
log_not_found off;
}
location ~* "^/themes/Frontend/Responsive/frontend/_public/src/fonts/(?:.+)\.(?:ttf|eot|svg|woff)$" {
expires max;
add_header Cache-Control "public";
access_log off;
log_not_found off;
}
location ~* "^/web/cache/(?:[0-9]{10})_(?:.+)\.(?:js|css)$" {
expires max;
add_header Cache-Control "public";
access_log off;
log_not_found off;
}
## All static files will be served directly.
location ~* ^.+\.(?:css|cur|js|jpe?g|gif|ico|png|html|xml)$ {
## Defining rewrite rules
rewrite files/documents/.* /engine last;
rewrite backend/media/(.*) /media/$1 last;
expires 1w;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
# The directive enables or disables messages in error_log about files not found on disk.
log_not_found off;
tcp_nodelay off;
## Set the OS file cache.
open_file_cache max=3000 inactive=120s;
open_file_cache_valid 45s;
open_file_cache_min_uses 2;
open_file_cache_errors off;
## Fallback to shopware
## comment in if needed
#try_files $uri @shopware;
}
index shopware.php index.php;
try_files $uri $uri/ /shopware.php?$args;
}
## XML Sitemap support.
location = /sitemap.xml {
log_not_found off;
access_log off;
try_files $uri @shopware;
}
## robots.txt support.
location = /robots.txt {
log_not_found off;
access_log off;
}
location @shopware {
rewrite / /shopware.php;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
include /etc/nginx/fastcgi_params;
## NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_split_path_info ^(.+\.php)(/.+)$;
## required for upstream keepalive
# disabled due to failed connections
#fastcgi_keep_conn on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SHOPWARE_ENV $shopware_env if_not_empty;
fastcgi_param ENV $shopware_env if_not_empty; # BC for older SW versions
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
client_max_body_size 24M;
client_body_buffer_size 128k;
## you may have to change to tcp connection instead of socket
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
@bcremer
Copy link

bcremer commented Nov 19, 2015

This configuration is taken from https://github.com/bcremer/shopware-with-nginx. Please always include a linkt to the original so people can find the most recent version of this configuration. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment