├── Dockerfile ├── bin └── start.sh ├── conf ├── nginx.conf └── default.conf ├── README.md └── LICENSE.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:1.11 2 | MAINTAINER Mark Shust 3 | 4 | ENV PHP_HOST phpfpm 5 | ENV PHP_PORT 9000 6 | ENV APP_MAGE_MODE default 7 | 8 | COPY ./conf/nginx.conf /etc/nginx/ 9 | COPY ./conf/default.conf /etc/nginx/conf.d/ 10 | COPY ./bin/start.sh /usr/local/bin/start.sh 11 | 12 | WORKDIR /var/www/html 13 | 14 | CMD ["/usr/local/bin/start.sh"] 15 | -------------------------------------------------------------------------------- /bin/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | [ ! -z "${PHP_HOST}" ] && sed -i "s/PHP_HOST/${PHP_HOST}/" /etc/nginx/conf.d/default.conf 3 | [ ! -z "${PHP_PORT}" ] && sed -i "s/PHP_PORT/${PHP_PORT}/" /etc/nginx/conf.d/default.conf 4 | [ ! -z "${APP_MAGE_MODE}" ] && sed -i "s/APP_MAGE_MODE/${APP_MAGE_MODE}/" /etc/nginx/conf.d/default.conf 5 | 6 | /usr/sbin/nginx -g "daemon off;" 7 | -------------------------------------------------------------------------------- /conf/nginx.conf: -------------------------------------------------------------------------------- 1 | 2 | user www-data; 3 | worker_processes 1; 4 | 5 | error_log /var/log/nginx/error.log debug; 6 | pid /var/run/nginx.pid; 7 | 8 | 9 | events { 10 | worker_connections 1024; 11 | } 12 | 13 | 14 | http { 15 | include /etc/nginx/mime.types; 16 | default_type application/octet-stream; 17 | 18 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 19 | '$status $body_bytes_sent "$http_referer" ' 20 | '"$http_user_agent" "$http_x_forwarded_for"'; 21 | 22 | access_log /var/log/nginx/access.log main; 23 | 24 | sendfile on; 25 | #tcp_nopush on; 26 | 27 | keepalive_timeout 65; 28 | 29 | #gzip on; 30 | 31 | include /etc/nginx/conf.d/*.conf; 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | This repo has been migrated into https://github.com/markoshust/magento2-docker - please see this repo for future updates! 4 | 5 | # Versions 6 | 7 | - [`1.11-1` (_Dockerfile_)](https://github.com/mageinferno/docker-magento2-nginx/tree/1.11-1/Dockerfile) 8 | 9 | # Description 10 | 11 | This image is built from [`nginx`](https://hub.docker.com/_/nginx/) and contains the default webserver configuration for Magento 2. 12 | 13 | # What's in this image? 14 | 15 | This image installs the following: 16 | 17 | - `nginx` 18 | 19 | # Variables 20 | 21 | The following environment variables are used for Nginx configuration: 22 | 23 | - `PHP_HOST`: (default: `phpfpm`) The hostname of the PHP container. 24 | - `PHP_PORT`: (default: `9000`) The port of the PHP container. 25 | - `APP_MAGE_MODE`: (default: `default`) Set the appropriate MAGE_MODE. 26 | 27 | # Docker Compose 28 | 29 | Please see [https://github.com/mageinferno/magento2-docker-compose](https://github.com/mageinferno/magento2-docker-compose) for more detailed instructions and an example development environment using Docker Compose. 30 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Mage Inferno 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /conf/default.conf: -------------------------------------------------------------------------------- 1 | upstream fastcgi_backend { 2 | server PHP_HOST:PHP_PORT; 3 | } 4 | 5 | server { 6 | listen 80; 7 | server_name localhost; 8 | 9 | set $MAGE_ROOT /var/www/html; 10 | set $MAGE_MODE APP_MAGE_MODE; 11 | 12 | root $MAGE_ROOT/pub; 13 | 14 | index index.php; 15 | autoindex off; 16 | charset off; 17 | 18 | add_header 'X-Content-Type-Options' 'nosniff'; 19 | 20 | location /setup { 21 | root $MAGE_ROOT; 22 | 23 | location ~ ^/setup/index.php { 24 | fastcgi_pass fastcgi_backend; 25 | fastcgi_index index.php; 26 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 27 | include fastcgi_params; 28 | } 29 | 30 | location ~ ^/setup/(?!pub/). { 31 | deny all; 32 | } 33 | 34 | location ~ ^/setup/pub/ { 35 | add_header X-Frame-Options "SAMEORIGIN"; 36 | } 37 | } 38 | 39 | location /update { 40 | root $MAGE_ROOT; 41 | 42 | location ~ ^/update/index.php { 43 | fastcgi_split_path_info ^(/update/index.php)(/.+)$; 44 | fastcgi_pass fastcgi_backend; 45 | fastcgi_index index.php; 46 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 47 | fastcgi_param PATH_INFO $fastcgi_path_info; 48 | include fastcgi_params; 49 | } 50 | 51 | # deny everything but index.php 52 | location ~ ^/update/(?!pub/). { 53 | deny all; 54 | } 55 | 56 | location ~ ^/update/pub/ { 57 | add_header X-Frame-Options "SAMEORIGIN"; 58 | } 59 | } 60 | 61 | location / { 62 | try_files $uri $uri/ /index.php?$args; 63 | } 64 | 65 | location /pub { 66 | location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { 67 | deny all; 68 | } 69 | 70 | alias $MAGE_ROOT/pub; 71 | add_header X-Frame-Options "SAMEORIGIN"; 72 | } 73 | 74 | location /static/ { 75 | if ($MAGE_MODE = "production") { 76 | expires max; 77 | } 78 | 79 | # remove signature of static files used to overcome browser cache 80 | location ~ ^/static/version { 81 | rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; 82 | } 83 | 84 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 85 | add_header Cache-Control "public"; 86 | add_header X-Frame-Options "SAMEORIGIN"; 87 | expires +1y; 88 | 89 | if (!-f $request_filename) { 90 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 91 | } 92 | } 93 | 94 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 95 | add_header Cache-Control "no-store"; 96 | add_header X-Frame-Options "SAMEORIGIN"; 97 | expires off; 98 | 99 | if (!-f $request_filename) { 100 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 101 | } 102 | } 103 | 104 | if (!-f $request_filename) { 105 | rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; 106 | } 107 | 108 | add_header X-Frame-Options "SAMEORIGIN"; 109 | } 110 | 111 | location /media/ { 112 | try_files $uri $uri/ /get.php?$args; 113 | 114 | location ~ ^/media/theme_customization/.*\.xml { 115 | deny all; 116 | } 117 | 118 | location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { 119 | add_header Cache-Control "public"; 120 | add_header X-Frame-Options "SAMEORIGIN"; 121 | expires +1y; 122 | try_files $uri $uri/ /get.php?$args; 123 | } 124 | 125 | location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { 126 | add_header Cache-Control "no-store"; 127 | add_header X-Frame-Options "SAMEORIGIN"; 128 | expires off; 129 | try_files $uri $uri/ /get.php?$args; 130 | } 131 | 132 | add_header X-Frame-Options "SAMEORIGIN"; 133 | } 134 | 135 | location /media/customer/ { 136 | deny all; 137 | } 138 | 139 | location /media/downloadable/ { 140 | deny all; 141 | } 142 | 143 | location /media/import/ { 144 | deny all; 145 | } 146 | 147 | location ~ /media/theme_customization/.*\.xml$ { 148 | deny all; 149 | } 150 | 151 | location /errors/ { 152 | try_files $uri =404; 153 | } 154 | 155 | location ~ ^/errors/.*\.(xml|phtml)$ { 156 | deny all; 157 | } 158 | 159 | location ~ cron\.php { 160 | deny all; 161 | } 162 | 163 | location ~ (index|get|static|report|404|503)\.php$ { 164 | try_files $uri =404; 165 | fastcgi_pass fastcgi_backend; 166 | 167 | fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; 168 | fastcgi_param PHP_VALUE "max_execution_time=600"; 169 | fastcgi_read_timeout 600s; 170 | fastcgi_connect_timeout 600s; 171 | fastcgi_param MAGE_MODE $MAGE_MODE; 172 | 173 | fastcgi_index index.php; 174 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 175 | include fastcgi_params; 176 | } 177 | } 178 | --------------------------------------------------------------------------------