diff --git a/resources/templates/apache2/vhost.template b/resources/templates/apache2/vhost.template new file mode 100644 index 0000000..27f4ebf --- /dev/null +++ b/resources/templates/apache2/vhost.template @@ -0,0 +1,125 @@ +# Official VirtualHost configuration for Apache 2.4 template +# See Readme.md for how to generate your config manually, or in automated deployments. +# Note: This is meant to be manually tailored for your needs, expires headers might for instance not work for your dev setup. + +# NameVirtualHost %IP_ADDRESS% + + + ServerName %HOST_NAME% + ServerAlias %HOST_ALIAS% + DocumentRoot %BASEDIR%/public + DirectoryIndex index.php + + # Request size limit in bytes, 0 to disable + LimitRequestBody %BODY_SIZE_LIMIT% + + # Request timeout limit in seconds, 0 to disable + TimeOut %TIMEOUT% + + # Enabled for Dev environment + #LogLevel debug + + # "public" folder is what we expose to the world, all rewrite rules further down are relative to it. + + + # For serving php files configure mod_proxy to talk to php-fpm using Apache 2.4.10 and higher. + # See: https://wiki.apache.org/httpd/PHP-FPM#apache_httpd_2.4 + + # For best performance, prefer socket use. This requires Linux, and that both Apache and PHP has access to + # the socket file `/var/run/php5-fpm.sock` via local file system and hence run on the same machine. + #SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/" + # For TCP usage, if you're not on Linux, or Apache and PHP are on separate machines, instead use fcgi: form. + # (Optionally hint php-fpm processes count using: https://wiki.apache.org/httpd/PHP-FPM#Proxy_via_handler) + #SetHandler "proxy:fcgi://localhost/:9000" + + SetHandler "proxy:%FASTCGI_PASS%|fcgi://localhost/" + + + Options FollowSymLinks + AllowOverride None + Require all granted + + + ## Ibexa DXP / Symfony ENVIRONMENT variables, for customizing index.php* execution + # * Only APP_ENV and APP_DEBUG supported by console command, rest are Ibexa DXP features in index.php. + + # Environment. + # Possible values: "prod" and "dev" out-of-the-box, other values possible with proper configuration + # Defaults to "dev" if omitted (uses SetEnvIf so value can be used in rewrite rules) + #if[APP_ENV] SetEnvIf Request_URI ".*" APP_ENV=%APP_ENV% + + # Optional: Whether to use debugging. + # Possible values: 0, 1 or "" + # Defaults to enabled if APP_ENV is set to "dev" if env value is omitted or empty + #if[APP_DEBUG] SetEnv APP_DEBUG "%APP_DEBUG%" + + # Optional: Whether to use Symfony's builtin HTTP Caching Proxy. + # Disable it if you are using an external reverse proxy (e.g. Varnish) + # Possible values: 0, 1 or "" + # Defaults to disabled if APP_ENV is set to "dev" or TRUSTED_PROXIES is set, + # and if this env value is omitted or empty + #if[APP_HTTP_CACHE] SetEnv APP_HTTP_CACHE "%APP_HTTP_CACHE%" + + # Optional: Defines the proxies to trust + # Needed when using Varnish as proxy, if so disable APP_HTTP_CACHE. + # Separate entries by a comma, example: "ip1,ip2" + # Defaults to not be set if env value is omitted or empty + #if[TRUSTED_PROXIES] SetEnv TRUSTED_PROXIES "%TRUSTED_PROXIES%" + + # TIP: There are many more environment variables supported by Ibexa DXP. However unlike those listed above + # they should in most cases rather be set in the environment then in vhost config to make sure cronjobs + # and cli command usage takes them into account as well. + + + RewriteEngine On + + # For FastCGI mode or when using PHP-FPM, to get basic auth working. + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + + # Disable .php(3) and other executable extensions in the var directory + RewriteRule ^var/.*(?i)\.(php3?|phar|phtml|sh|exe|pl|bin)$ - [F] + + # Cluster/streamed files rewrite rules. Enable on cluster with DFS as a binary data handler + RewriteCond %{ENV:BINARY_DATA_HANDLER} "dfs" + RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* /index.php [L] + + RewriteRule ^/var/([^/]+/)?storage/images(-versioned)?/.* - [L] + + # Makes it possible to placed your favicon and robots.txt at the root of your public folder + RewriteRule ^/favicon\.ico - [L] + RewriteRule ^/robots\.txt - [L] + + # The following rules are needed to correctly display bundle and project assets + RewriteRule ^/bundles/ - [L] + RewriteRule ^/assets/ - [L] + RewriteRule ^/build/ - [L] + + # Additional Assetic rules for environments different from dev, + # remember to run php bin/console assetic:dump --env=prod + RewriteCond %{ENV:APP_ENV} !^(dev) + RewriteRule ^/(css|js|fonts?)/.*\.(css|js|otf|eot|ttf|svg|woff) - [L] + + # Prevent access to website with direct usage of index.php in URL + RewriteRule ^/([^/]+/)?index\.php([/?#]|$) - [R=404,L] + + RewriteRule .* /index.php + + + # Everything below is optional to improve performance by forcing + # clients to cache image and design files, change the expires time + # to suite project needs. + + + # Ibexa DXP appends the version number to image URL (image + # datatype) so when an image is updated, its URL changes too + ExpiresActive on + ExpiresDefault "now plus 10 years" + + + + # Enable gzip encoding + + AddOutputFilterByType DEFLATE text/plain text/css application/json text/javascript application/javascript text/xml application/xml application/xml+rss + # NOTE: Using gzip on text/html can be a security issue. See http://breachattack.com. + + diff --git a/resources/templates/nginx/ibexa_params.d/ibexa_fastcgi_params b/resources/templates/nginx/ibexa_params.d/ibexa_fastcgi_params new file mode 100644 index 0000000..f433ab3 --- /dev/null +++ b/resources/templates/nginx/ibexa_params.d/ibexa_fastcgi_params @@ -0,0 +1,23 @@ + +# Including the distribution's default fastcgi parameters +include fastcgi_params; + +fastcgi_buffer_size 128k; +fastcgi_buffers 4 256k; +fastcgi_busy_buffers_size 256k; + +set $fc_script_name "index.php"; + +if ( $uri ~ "^/(.*\.php)" ) { + set $fc_script_name $1; +} + +fastcgi_split_path_info ^(.+\.php)(/.+)$; + +fastcgi_param PATH_INFO $fastcgi_path_info; +fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; +fastcgi_param SCRIPT_NAME $fc_script_name; +fastcgi_param SCRIPT_FILENAME $document_root/$fc_script_name; + +fastcgi_index index.php; + diff --git a/resources/templates/nginx/ibexa_params.d/ibexa_prod_rewrite_params b/resources/templates/nginx/ibexa_params.d/ibexa_prod_rewrite_params new file mode 100644 index 0000000..1609cc8 --- /dev/null +++ b/resources/templates/nginx/ibexa_params.d/ibexa_prod_rewrite_params @@ -0,0 +1,11 @@ + +# Additional Assetic rules +## Don't forget to run php bin/console assetic:dump --env=prod +## and make sure to comment these out in DEV environment. +rewrite "^/css/(.*)\.css" "/css/$1.css" break; +rewrite "^/js/(.*)\.js" "/js/$1.js" break; +rewrite "^/font(s?)/(.*)\.ttf" "/font$1/$2.ttf" break; +rewrite "^/font(s?)/(.*)\.woff" "/font$1/$2.woff" break; +rewrite "^/font(s?)/(.*)\.otf" "/font$1/$2.otf" break; +rewrite "^/font(s?)/(.*)\.eot" "/font$1/$2.eot" break; +rewrite "^/font(s?)/(.*)\.svg" "/font$1/$2.svg" break; diff --git a/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_dfsimage_params b/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_dfsimage_params new file mode 100644 index 0000000..d1cacbb --- /dev/null +++ b/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_dfsimage_params @@ -0,0 +1 @@ +rewrite "^/var/([^/]+/)?storage/images(-versioned)?/(.*)" "/index.php" break; diff --git a/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_image_params b/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_image_params new file mode 100644 index 0000000..d9ea968 --- /dev/null +++ b/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_image_params @@ -0,0 +1 @@ +rewrite "^/var/([^/]+/)?storage/images(-versioned)?/(.*)" "/var/$1storage/images$2/$3" break; diff --git a/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_params b/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_params new file mode 100644 index 0000000..a0b05a3 --- /dev/null +++ b/resources/templates/nginx/ibexa_params.d/ibexa_rewrite_params @@ -0,0 +1,27 @@ +rewrite "^/var/([^/]+/)?storage/images(-versioned)?/(.*)" "/var/$1storage/images$2/$3" break; + +# Makes it possible to place your favicon at the root of your +# Ibexa DXP instance. It will then be served directly. +rewrite "^/favicon\.ico" "/favicon.ico" break; + +# Give direct access to robots.txt for use by crawlers (Google, +# Bing, Spammers..) +rewrite "^/robots\.txt" "/robots.txt" break; + +# Platform for Privacy Preferences Project ( P3P ) related files +# for Internet Explorer +# More info here : http://en.wikipedia.org/wiki/P3p +rewrite "^/w3c/p3p\.xml" "/w3c/p3p.xml" break; + +# Following rule is needed to correctly display bundle and project assets +rewrite "^/bundles/(.*)" "/bundles/$1" break; +rewrite "^/build/(.*)" "/build/$1" break; +rewrite "^/assets/(.*)" "/assets/$1" break; + +# Prevent access to website with direct usage of index.php in URL +if ($request_uri ~ "^/([^/]+/)?index\.php([/?#]|$)") { + return 404; +} + +rewrite "^(.*)$" "/index.php$1" last; + diff --git a/resources/templates/nginx/ibexa_params.d/ibexa_server_params b/resources/templates/nginx/ibexa_params.d/ibexa_server_params new file mode 100644 index 0000000..c67a00f --- /dev/null +++ b/resources/templates/nginx/ibexa_params.d/ibexa_server_params @@ -0,0 +1,7 @@ + +disable_symlinks off; + +location = /favicon.ico { + log_not_found off; + access_log off; +} diff --git a/resources/templates/nginx/vhost.template b/resources/templates/nginx/vhost.template new file mode 100644 index 0000000..7224af1 --- /dev/null +++ b/resources/templates/nginx/vhost.template @@ -0,0 +1,79 @@ + +server { + listen %PORT%; + # Further documentation: http://nginx.org/en/docs/http/server_names.html + server_name %HOST_LIST%; + + root %BASEDIR%/public; + + # Additional Assetic rules + ## Don't forget to run php bin/console assetic:dump --env=prod + ## and make sure to comment these out in DEV environment. + #if[APP_ENV!=dev] include ibexa_params.d/ibexa_prod_rewrite_params; + + # Include image rule for DFS or binary handler + include ibexa_params.d/ibexa_rewrite_%BINARY_DATA_HANDLER%image_params; + + # Include remaining Ibexa rewrite rules + include ibexa_params.d/ibexa_rewrite_params; + + # upload max size + client_max_body_size %BODY_SIZE_LIMIT_M%; + + # FPM fastcgi_read_timeout + fastcgi_read_timeout %TIMEOUT_S%; + + # Gzip is enabled by default on most platforms, so here we just specify mime types to compress. + # NOTE: Using gzip on text/html can be a security issue, unless you somehow pad. See http://breachattack.com + gzip_types text/plain text/css application/json text/javascript application/javascript text/xml application/xml application/xml+rss; + + location / { + location ~ ^/index\.php(/|$) { + include ibexa_params.d/ibexa_fastcgi_params; + + # FPM socket + # Possible values : unix:/var/run/php5-fpm.sock or 127.0.0.1:9000 + fastcgi_pass %FASTCGI_PASS%; + + ## Ibexa DXP ENVIRONMENT variables, used for customizing index.php execution (not used by console commands) + + # Environment. + # Possible values: "prod" and "dev" out-of-the-box, other values possible with proper configuration + # Make sure to comment the "ibexa_params.d/ibexa_prod_rewrite_params" include above in dev. + # Defaults to "dev" if omitted + #if[APP_ENV] fastcgi_param APP_ENV %APP_ENV%; + + # Whether to use debugging. + # Possible values: 0 or 1 + # Defaults to 0 if omitted, unless APP_ENV is set to: "dev" + #if[APP_DEBUG] fastcgi_param APP_DEBUG "%APP_DEBUG%"; + + # Optional: Whether to use Symfony's builtin HTTP Caching Proxy. + # Disable it if you are using an external reverse proxy (e.g. Varnish) + # Possible values: 0 or 1 + # Defaults to 1 if omitted, unless APP_ENV is set to: "dev" + #if[APP_HTTP_CACHE] fastcgi_param APP_HTTP_CACHE "%APP_HTTP_CACHE%"; + + # Optional: Defines the proxies to trust + # Needed when using Varnish as proxy, if so disable APP_HTTP_CACHE. + # Separate entries by a comma, example: "ip1,ip2" + # Defaults to not be set if env value is omitted or empty + #if[TRUSTED_PROXIES] fastcgi_param TRUSTED_PROXIES "%TRUSTED_PROXIES%"; + + # TIP: There are many more environment variables supported by Ibexa DXP. However unlike those listed above + # they should in most cases rather be set in the environment then in vhost config to make sure cronjobs + # and cli command usage takes them into account as well. + } + + # Disable .php(3) and other executable extensions in the var directory + location ~ ^/var/.*(?i)\.(php3?|phar|phtml|sh|exe|pl|bin)$ { + return 403; + } + } + + # Custom logs + # access_log %BASEDIR%/app/logs/httpd-access.log; + # error_log %BASEDIR%/app/logs/httpd-error.log notice; + + include ibexa_params.d/ibexa_server_params; +}