do-dokku-wordpress icon indicating copy to clipboard operation
do-dokku-wordpress copied to clipboard

How to persist uploads?

Open mewben opened this issue 7 years ago • 11 comments

Upload is working until you push an update. They're all gone. :(

mewben avatar Nov 19 '16 14:11 mewben

Create storage dir for uploads:

cd /var/lib/dokku/data/storage
mkdir MYAPPNAME && cd MYAPPNAME
mkdir uploads
chown -R 32767:32767 .

Mount Storage in App:

dokku storage:mount MYAPPNAME /var/lib/dokku/data/storage/MYAPPNAME/uploads/:/app/wordpress/wp-content/uploads/

lucasjahn avatar Apr 02 '17 23:04 lucasjahn

In my case I can't upload any image :(

Error: Failed to load resource: the server responded with a status of 403 (Forbidden) /wordpress/wp-admin/async-upload.php

Any help, please? :S

eusthace811 avatar Apr 06 '17 06:04 eusthace811

@jlsuarezs Did you saw my comment and tried it with this storage? Otherwhise it won't work if you don't create a shared volume. You have to pay attention to the rights of that folder too (chown)

lucasjahn avatar Apr 06 '17 06:04 lucasjahn

Hi! Yes, now is working after change app to MYAPPNAME:

dokku storage:mount MYAPPNAME /var/lib/dokku/data/storage/MYAPPNAME/uploads/:/MYAPPNAME/wordpress/wp-content/uploads/

My new issue is that I am running in https, when I try to crop the image:

Error: There has been an error cropping your image.

Mixed Content: The page at 'https://MYDOMAIN.com/wordpress/wp-admin/customize.php?return=%2Fwordpress%2Fwp-admin%2F' was loaded over HTTPS, but requested an insecure image 'http://MYDOMAIN.com/wordpress//app/public/uploads/2017/04/image.png'. This content should also be served over HTTPS.

Ouch, how can I fix the SSL issue now? :(

Thank you so much for your help!!

eusthace811 avatar Apr 06 '17 06:04 eusthace811

No problem at all :)

Okay I had similar issues. What you should check is first your domain is set everywhere as https:

  1. check your config this command and see if there is a http instead a https somewhere:
dokku config MYAPPNAME
  1. add this code snippet to your wp-config.php
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
    && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] )
{
    $_SERVER['HTTPS'] = 'on';
}
  1. check that your wp-config vars contain the env var for domain name and url
define('WP_SITEURL', 'https://'. getenv('DOMAIN_NAME'));
define('WP_HOME',  'https://'. getenv('DOMAIN_NAME'));

and set these env var with (but just use MYDOMAIN.com without protocol):

dokku config:set MYAPPNAME DOMAIN_NAME=MYDOMAIN

lucasjahn avatar Apr 06 '17 06:04 lucasjahn

Thank you again!

Yes, I've done all this before. Finally this plugin solved the SSL issue completely: Really Simple SSL Plugin

The thing is that I still can't upload any image, after crop I still have the same problem :(

eusthace811 avatar Apr 06 '17 06:04 eusthace811

What error message do you get now?

lucasjahn avatar Apr 06 '17 06:04 lucasjahn

You could also try this plugin to update all your http URLs. It worked quite well for me:

https://de-ch.wordpress.org/plugins/velvet-blues-update-urls/

lucasjahn avatar Apr 06 '17 06:04 lucasjahn

Hhumm, I think there is something more. I have two issues when I try to customize the theme (appearance > customize) > my session is always expired and the image error: GET https://MYDOMAIN.com/wordpress/wp-content/uploads/2017/04/logo.png 404 (Not Found)

eusthace811 avatar Apr 06 '17 07:04 eusthace811

Ohh, found that the uploads folder is not inside wp-content, after move in is working!!

And the correct command is yours: dokku storage:mount MYAPPNAME /var/lib/dokku/data/storage/MYAPPNAME/uploads/:/app/wordpress/wp-content/uploads/

So, just to let you know we need to mount 3 folders:

dokku storage:mount MYAPPNAME /var/lib/dokku/data/storage/MYAPPNAME/plugins/:/app/wordpress/wp-content/plugins/

dokku storage:mount MYAPPNAME /var/lib/dokku/data/storage/MYAPPNAME/themes/:/app/wordpress/wp-content/themes/

dokku storage:mount MYAPPNAME /var/lib/dokku/data/storage/MYAPPNAME/uploads/:/app/wordpress/wp-content/uploads/

Now I just need to find why the session is always expired when customizing the theme...:S

Thank you!

eusthace811 avatar Apr 06 '17 07:04 eusthace811

@jlsuarezs were you able to figure out a solution to the session expiration when customizing your theme issue? I am running into the same thing.

umer98 avatar Mar 17 '18 23:03 umer98