From 083b6f1f18dbfef14d724a592d1bea6bcfc052fc Mon Sep 17 00:00:00 2001 From: jedi Date: Tue, 17 Dec 2019 14:10:46 +0100 Subject: [PATCH] fix 405 error in docker --- app/Http/Controllers/ItemController.php | 4 ++-- app/Item.php | 2 +- container/web/general.conf | 9 +++++++++ container/web/images.conf | 7 +++++++ container/web/{01_init.sh => init.sh} | 0 container/web/location-root.conf | 15 +++++++++++++++ docker-compose.yml | 7 +++++-- 7 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 container/web/general.conf create mode 100644 container/web/images.conf rename container/web/{01_init.sh => init.sh} (100%) create mode 100644 container/web/location-root.conf diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index 6847cb6..d7503e8 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -45,8 +45,8 @@ class ItemController extends Controller { $eid = Event::where('slug','=',$event)->first()->eid; $data = $request->all(); - $data['eid'] = $eid; - $item = Item::create($request->all()); + $data['eid'] = "".$eid; + $item = Item::create($data); return response()->json($item, 201); } diff --git a/app/Item.php b/app/Item.php index 25760d7..f1ce096 100644 --- a/app/Item.php +++ b/app/Item.php @@ -26,6 +26,6 @@ class Item extends Model * * @var array */ - protected $hidden = ['created_at','updated_at', 'deleted_at', 'eid']; + protected $hidden = ['created_at','updated_at', 'deleted_at', 'eid', 'cid', 'iid']; } diff --git a/container/web/general.conf b/container/web/general.conf new file mode 100644 index 0000000..3e00bb2 --- /dev/null +++ b/container/web/general.conf @@ -0,0 +1,9 @@ +add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;"; +add_header X-Content-Type-Options nosniff; +add_header X-XSS-Protection "1; mode=block"; +add_header X-Robots-Tag none; +add_header X-Download-Options noopen; +add_header X-Permitted-Cross-Domain-Policies none; +add_header Access-Control-Allow-Origin '*'; + +client_max_body_size 50m; diff --git a/container/web/images.conf b/container/web/images.conf new file mode 100644 index 0000000..1d36242 --- /dev/null +++ b/container/web/images.conf @@ -0,0 +1,7 @@ +rewrite '^/1/images/([0-9a-fA-F]{32})/?$' /staticimages/$1 last; +rewrite '^/1/thumbs/([0-9a-fA-F]{32})/?$' /thumbnails/$1 last; +# rewrite '^/thumbnails/([0-9a-fA-F]{32})$' /thumbnail.php?id=$1 last; + +location /thumbnails/ { + try_files $uri /thumbnail.php?id=$uri; +} diff --git a/container/web/01_init.sh b/container/web/init.sh similarity index 100% rename from container/web/01_init.sh rename to container/web/init.sh diff --git a/container/web/location-root.conf b/container/web/location-root.conf new file mode 100644 index 0000000..a8b6892 --- /dev/null +++ b/container/web/location-root.conf @@ -0,0 +1,15 @@ +location / { + if ($request_method = OPTIONS) { + add_header Content-Length 0; + add_header Content-Type text/plain; + add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"; + add_header Access-Control-Allow-Origin '*'; #$http_origin; + add_header Access-Control-Allow-Headers "Authorization, Content-Type"; + add_header Access-Control-Allow-Credentials true; + return 200; + } + + try_files $uri $uri/ /index.php?$query_string; + + +} diff --git a/docker-compose.yml b/docker-compose.yml index c0b81fe..9f74ae8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,10 @@ services: - "80:80" volumes: - ./:/app - - ./container/web/:/entrypoint.d + - ./container/web/init.sh:/entrypoint.d/09-init.sh + - ./container/web/location-root.conf:/opt/docker/etc/nginx/vhost.common.d/10-location-root.conf + - ./container/web/general.conf:/opt/docker/etc/nginx/vhost.common.d/10-general.conf + - ./container/web/images.conf:/opt/docker/etc/nginx/vhost.common.d/20-images.conf environment: WEB_DOCUMENT_ROOT: /app/public XDEBUG_REMOTE_HOST: marvin @@ -28,7 +31,7 @@ services: - backend restart: on-failure ports: - - "${DB_PORT}:3306" + - "3306:3306" volumes: - ./.local/db:/var/lib/mysql - ./container/db/:/docker-entrypoint-initdb.d