From 0db4d252b572a3c9355e9bf849b0a6a73cc53f5a Mon Sep 17 00:00:00 2001 From: Brett O'Donnell Date: Thu, 12 Apr 2018 17:56:05 +0930 Subject: [PATCH] update and cleanup --- .../etc/letsencrypt/live/app/fullchain.pem | 56 +++++++ .../etc/letsencrypt/live/app/privkey.pem | 28 ++++ build/nginx/config/etc/nginx/nginx.conf | 157 ++++++++++++++++++ .../etc/phpmyadmin/config.dev.inc.php | 4 + composer.json | 2 +- docker-compose.override.yml | 31 ++++ docker-compose.yml | 58 +++++++ src/commands/PackageController.php | 2 +- src/config/db.php | 2 +- src/controllers/ModController.php | 6 +- .../m150812_000001_create_package.php | 2 +- 11 files changed, 343 insertions(+), 5 deletions(-) create mode 100644 build/nginx/config/etc/letsencrypt/live/app/fullchain.pem create mode 100644 build/nginx/config/etc/letsencrypt/live/app/privkey.pem create mode 100644 build/nginx/config/etc/nginx/nginx.conf create mode 100644 build/phpmyadmin/etc/phpmyadmin/config.dev.inc.php create mode 100644 docker-compose.override.yml create mode 100644 docker-compose.yml diff --git a/build/nginx/config/etc/letsencrypt/live/app/fullchain.pem b/build/nginx/config/etc/letsencrypt/live/app/fullchain.pem new file mode 100644 index 0000000..cdb1e8e --- /dev/null +++ b/build/nginx/config/etc/letsencrypt/live/app/fullchain.pem @@ -0,0 +1,56 @@ +-----BEGIN CERTIFICATE----- +MIIFCjCCA/KgAwIBAgISAwEyTcIlQD5Zmxo7q5zJnXnlMA0GCSqGSIb3DQEBCwUA +MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD +ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xODAxMTIxMTQ2MTdaFw0x +ODA0MTIxMTQ2MTdaMBYxFDASBgNVBAMTC2Rldi5hZmkuaW5rMIIBIjANBgkqhkiG +9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtAFk1KEICuGQxrWKNNBttZcuD5tQrt9ujqw2 +2Dyh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AvA2H3DkwIDAQABo4IBfTCCAXkwEgYDVR0T +AQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAYYwfwYIKwYBBQUHAQEEczBxMDIG +CCsGAQUFBzABhiZodHRwOi8vaXNyZy50cnVzdGlkLm9jc3AuaWRlbnRydXN0LmNv +bTA7BggrBgEFBQcwAoYvaHR0cDovL2FwcHMuaWRlbnRydXN0LmNvbS9yb290cy9k +c3Ryb290Y2F4My5wN2MwHwYDVR0jBBgwFoAUxKexpHsscfrb4UuQdf/EFWCFiRAw +VAYDVR0gBE0wSzAIBgZngQwBAgEwPwYLKwYBBAGC3xMBAQEwMDAuBggrBgEFBQcC +ARYiaHR0cDovL2Nwcy5yb290LXgxLmxldHNlbmNyeXB0Lm9yZzA8BgNVHR8ENTAz +MDGgL6AthitodHRwOi8vY3JsLmlkZW50cnVzdC5jb20vRFNUUk9PVENBWDNDUkwu +Y3JsMB0GA1UdDgQWBBSoSmpjBH3duubRObemRWXv86jsoTANBgkqhkiG9w0BAQsF +AAOCAQEA3TPXEfNjWDjdGBX7CVW+dla5cEilaUcne8IkCJLxWh9KEik3JHRRHGJo +uM2VcGfl96S8TihRzZvoroed6ti6WqEBmtzw3Wodatg+VyOeph4EYpr/1wXKtx8/ +wApIvJSwtmVi4MFU5aMqrSDE6ea73Mj2tcMyo5jMd6jmeWUHK8so/joWUoHOUgwu +X4Po1QYz+3dszkDqMp4fklxBwXRsW10KXzPMTZ+sOPAveyxindmjkW8lGy+QsRlG +PfZ+G6Z6h7mjem0Y+iWlkYcV4PIWL1iwBi8saCbGS5jN2p8M+X+Q7UNKEkROb3N6 +KOqkqm57TH2H3eDJAkSnh6/DNFu0Qg== +-----END CERTIFICATE----- diff --git a/build/nginx/config/etc/letsencrypt/live/app/privkey.pem b/build/nginx/config/etc/letsencrypt/live/app/privkey.pem new file mode 100644 index 0000000..4962581 --- /dev/null +++ b/build/nginx/config/etc/letsencrypt/live/app/privkey.pem @@ -0,0 +1,28 @@ +-----B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B67vys7sIuUrGMszg1UDiMptAnEIoo4KsnDkFmGCvC +kcfc5Q1LFQKBgQDeZ2f7/Hrp8KDMFIb0dv+m6QtZAj7NbbzCR3KZQQxNqktbdpah +qQHca0iMGlEPIvulRFE6YRTD878gfWV1N64ZS8S/Tab/0e45uWBfSIvSD0BEPd55 ++XbZdbuaOheUjy+3AVY0jZxxqAkE438dfISdemLuhz8Gi2uTNEwgMoCpGwKBgQCx +mG87mtDEglnYpwcIBRRG7N+tC6iGUmUuJ9VAu/zo3xhvopQpwy/tFzg3heRIK8RD +7Tej5jJdGqXA9rFp9vpa1D21TxjLEpZCGlNCsnDycCbro7K8wTOLHY3cIuQ3+3gN +k1NrHu0WZ7kNvZ5ITKEdQw/YnBnEMrzKNtAAhQXndQKBgQCQXu+oEpoFVvv3Nwya +VYVaveo7AhnpvoNpf5CKS52nkjLX9QiewbyAmHRCKALxG11VSgND8ex0pAWWksIh +tq8/UelTz/3ZmcDBtFxnqwpH61Cn9qNIuB+29pTOQXrz9UpisETY0hg5cLRPxTDH +zSkjsLCcWYdsLY3592yti/axEw== +-----END PRIVATE KEY----- diff --git a/build/nginx/config/etc/nginx/nginx.conf b/build/nginx/config/etc/nginx/nginx.conf new file mode 100644 index 0000000..4513cf3 --- /dev/null +++ b/build/nginx/config/etc/nginx/nginx.conf @@ -0,0 +1,157 @@ + +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + log_format logstash_json '{ "@timestamp": "$time_iso8601", ' + '"@fields": { ' + '"remote_addr": "$remote_addr", ' + '"remote_user": "$remote_user", ' + '"body_bytes_sent": "$body_bytes_sent", ' + '"request_time": "$request_time", ' + '"status": "$status", ' + '"request": "$request", ' + '"request_method": "$request_method", ' + '"http_x_forwarded_for": "$http_x_forwarded_for", ' + '"http_referrer": "$http_referer", ' + '"http_user_agent": "$http_user_agent" } }'; + + access_log /var/log/nginx/access.log logstash_json; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + ssl_session_cache shared:SSL:10m; + ssl_session_timeout 10m; + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; + ssl_ciphers AES256+EECDH:AES256+EDH:!aNULL; + ssl_stapling on; + ssl_stapling_verify on; + #resolver ; + ssl_dhparam /etc/nginx/dhparam/dhparam.pem; + + # gzip should not be used with ssl + gzip off; + + # larger uploads + client_max_body_size 64M; + + # HTTP server + server { + charset utf-8; + server_name afi.ink; + + listen 80 default_server; + + root /app/web; + index index.php; + + # ACME webroot for https://github.com/bringnow/docker-nginx-letsencrypt + location /.well-known/acme-challenge { + alias /var/acme-webroot/.well-known/acme-challenge; + location ~ /.well-known/acme-challenge/(.*) { + add_header Content-Type application/jose+json; + } + } + + # redirect all traffic to https + # note: if uncommenting this, comment out anything further in this server definition + #location / { + # return 301 https://$host$request_uri; + #} + + # Redirect everything that isn't a real file to index.php + location / { + try_files $uri $uri/ /index.php?$args; + } + + # uncomment to avoid processing of calls to non-existing static files by Yii + location ~ \.(js|css|swf|ico|mov|fla|zip|rar)$ { + try_files $uri =404; + } + + # print-spool + location /print-spool { + index index.html; + try_files $uri $uri/ /index.php?$args; + } + + # send php files to phpfpm + location ~ \.php$ { + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + fastcgi_pass php:9000; + try_files $uri =404; + } + + # deny secret files + location ~ /\.(ht|svn|git) { + deny all; + } + } + + # HTTPS server + server { + charset utf-8; + + server_name app; + listen 443 ssl default_server; + root /app/web; + index index.php; + + # setup SSL + ssl_certificate /etc/letsencrypt/live/app/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/app/privkey.pem; + add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always; + + # redirect everything that isn't a real file to index.php + location / { + try_files $uri $uri/ /index.php?$args; + } + + # avoid processing of calls to non-existing static files by Yii + location ~ \.(js|css|swf|ico|mov|fla|zip|rar)$ { + try_files $uri =404; + } + + # send php files to phpfpm + location ~ \.php$ { + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + fastcgi_pass php:9000; + try_files $uri =404; + } + + # print-spool + location /print-spool { + index index.html; + try_files $uri $uri/ /index.php?$args; + } + + # deny secret files + location ~ /\.(ht|svn|git) { + deny all; + } + } + + + include /etc/nginx/conf.d/*.conf; +} diff --git a/build/phpmyadmin/etc/phpmyadmin/config.dev.inc.php b/build/phpmyadmin/etc/phpmyadmin/config.dev.inc.php new file mode 100644 index 0000000..4ad2f5c --- /dev/null +++ b/build/phpmyadmin/etc/phpmyadmin/config.dev.inc.php @@ -0,0 +1,4 @@ +stdout('Importing restore from ' . $file . "\n"); $data = json_decode(file_get_contents($file), true); $count = count($data); diff --git a/src/config/db.php b/src/config/db.php index 71fd63f..f9b2470 100644 --- a/src/config/db.php +++ b/src/config/db.php @@ -12,7 +12,7 @@ if (YII_ENV == 'prod') { } return [ 'class' => 'yii\db\Connection', - 'dsn' => 'mysql:host=localhost;dbname=minetest_bower', + 'dsn' => 'mysql:host=db;dbname=minetest', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8', diff --git a/src/controllers/ModController.php b/src/controllers/ModController.php index 9a11855..3d48508 100644 --- a/src/controllers/ModController.php +++ b/src/controllers/ModController.php @@ -24,7 +24,7 @@ class ModController extends Controller public $enableCsrfValidation = false; /** - * Lists all Package models. + * Browse Package models. * @return mixed */ public function actionIndex() @@ -60,6 +60,7 @@ class ModController extends Controller * Displays a single Package model. * @param string $name * @return mixed + * @throws NotFoundHttpException */ public function actionView($name) { @@ -82,6 +83,7 @@ class ModController extends Controller * Displays a single Package models bower info. * @param string $name * @return mixed + * @throws NotFoundHttpException */ public function actionBower($name) { @@ -95,6 +97,7 @@ class ModController extends Controller * Displays a single Package models readme info. * @param string $name * @return mixed + * @throws NotFoundHttpException */ public function actionReadme($name) { @@ -108,6 +111,7 @@ class ModController extends Controller * Displays a single Package models readme info. * @param string $name * @return mixed + * @throws NotFoundHttpException */ public function actionScreenshots($name) { diff --git a/src/migrations/m150812_000001_create_package.php b/src/migrations/m150812_000001_create_package.php index c839165..f0a332a 100644 --- a/src/migrations/m150812_000001_create_package.php +++ b/src/migrations/m150812_000001_create_package.php @@ -9,7 +9,6 @@ class m150812_000001_create_package extends Migration public function up() { - $this->dropTable(self::TABLE); $this->createTable(self::TABLE, [ 'id' => Schema::TYPE_PK, 'name' => Schema::TYPE_STRING . '(50) NOT NULL', @@ -35,5 +34,6 @@ class m150812_000001_create_package extends Migration public function down() { + $this->dropTable(self::TABLE); } } \ No newline at end of file