Uploaded images not showing up on ushahidi 3


#1

I am setting up my ushahidi instance. I’ve uploaded a logo for the site. It is on the server - but it is not showing up in a browser. Could my .htaccess files be not directing apache?

Here’s the site:
https://usha.updig.is/views/map

The browser is looking in: src=“https://usha.updig.is/media/uploads/5/9/5931721871246-updig.jpg” which is not the right place - but the .htaccess file should bounce it to the right place - right?

Any clues as to what is going on?

thanks!


#2

I think you will need to tweak your application/config/cdn.php file, so that the “baseurl” is set to “/platform/httpdocs/index.php/”. Hope that helps

.htaccess should help shorten that . But so far I haven’t been able to verify how those .htaccess files are working in Dreamhost.


#3

Having this exact same problem. I upgraded to 3.7.0 and still having it. My site shows broken images like yours, @ryestew. I tried changing the baseurl as @davidlosada suggested, but didn’t help.

With the change, my access log is (swapped out the actual domain with “example.org”):

24.180.39.147 - - [28/Jun/2017:20:43:02 +0000] "GET /platform/httpdocs/index.php/5/9/592df99d5527f-cp%2002%20092116
.jpg HTTP/1.1" 404 1078 "http://example.org/views/map" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleW
ebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 OPR/45.0.2552.898"

Been searching and experimenting all day on this and unsure what to try next.


#4

What you essentially need is any non-existing URLs for the client being internally redirected (within the web server request handling) to /index.html .

This is a usual requisite in many AngularJS based applications using ui-router (see https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode )

The way to achieve this is dependent on your hosting.


#5

Actually I’ll follow up on that too - I haven’t fixed my problem - but then I haven’t tried recently to fix it. I’ll check this wiki.


#6

@ryestew best of luck on that… I’ve felt like I’ve scoured the wiki as much as humanly possible.

As a reference, I am using Apache and the structure is as follows:

  • /var/www/html/ - contains config.js, css, img, index.html, js, locales, platform, templates
  • /var/www/html/platform/ - contains 3.7.0 released version platform from GitHub Platform Release page
  • /var/www/html/platform/application/media/uploads/ - contains the files that are uploaded from the web interface (they are physically there, as expected)
  • /var/www/html/platform/httpdocs/ - is where the index.php file lives

The .htaccess file in /var/www/html/ is:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /index.html  [PT,L]

The .htaccess file in /var/www/html/platform/ is:

# Turn on URL rewriting
RewriteEngine On

# Set base directory
RewriteBase /platform

# Protect hidden files from being viewed
<Files .*>
        Order Deny,Allow
        Deny From All
</Files>

RewriteRule .* httpdocs/$0 [PT]

The .htaccess file for /var/www/html/platform/httpdocs/ is like the one that you mentioned on the AngularJS FAQ, @davidlosada:

# Turn on URL rewriting only when mod rewrite is turn on
<IfModule mod_rewrite.c>
    RewriteEngine On
        # Installation directory
        RewriteBase /platform/httpdocs
        # Protect application and system files from being viewed
        RewriteRule ^(application|modules|system|tests|sql) - [F,L]
        # Allow any files or directories that exist to be displayed directly
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteCond %{REQUEST_FILENAME} !-d
        # Rewrite all other URLs to index.php/URL
        RewriteRule .* index.php/$0 [PT]
</IfModule>
# Protect the htaccess from being viewed
<Files .htaccess>
        order allow,deny
        deny from all
</Files>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
#Follow symlinks
Options +FollowSymlinks

Also, just for fun is the Apache site config file /etc/apache2/sites-enabled/000-default.conf:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com
        <Directory /var/www/html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

#7

One more thing in the checklist … is mod_rewrite loaded and enabled into the apache process?


#8

I dropped a phpinfo.php in /var/www/html/ and it says it is loaded:

For the enabled part, every .htaccess has RewriteEngine on at the top, which I think means would enable it, right?

Thanks for your help, @davidlosada. I’ve done extensive searching and reading and experimenting on this. Have been at a big dead-end that I’d love to get past.


#9

@EliotLandrum How about the contents of application/config/cdn.php and application/config/media.php ?


#10

Here is cdn.php (I tried those three variations of baseurl):

<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Kohana CDN Config
 *
 * @author     Ushahidi Team <team@ushahidi.com>
 * @package    Ushahidi\Application\Config
 * @copyright  2015 Ushahidi
 * @license    https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
 */
return array(
        'baseurl' => false,
        // 'baseurl' => '/platform/httpdocs/index.php/',
        // 'baseurl' => '/platform/application/media/uploads/',
        // The default configuration using a local file system setup
        'type' => 'local',
        'local' => [
                // Where to upload media files eg. images. Take note of the trailing slash.
                // This should be in the Document root.
                'media_upload_dir' => APPPATH.'media'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR,
        ]
        // AWS S3 v3 CDN config example
        /*
        'type' => 'aws',
        'aws' => [
                'key'         => '',
                'secret'      => '',
                'region'      => '',
                'version'     => '',
                'bucket_name' => '',
        ]
        */
        // Rackspace CDN config example
        /*
        'type' => 'rackspace',
                'rackspace' => [
                'username'  => '',
                'apiKey'    => '',
                'region'    => '',
                'container' => ''
        ]
        */
);

And media.php (no changes to this file):

<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Kohana Media Config
 *
 * @author     Ushahidi Team <team@ushahidi.com>
 * @package    Ushahidi\Application\Config
 * @copyright  2013 Ushahidi
 * @license    https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
 */
return array(
        // The public accessible directory where the file will be copied
        'public_dir' => DOCROOT.'media/<uid>/<filepath>',
        // Write the files to the public directory when in production
        'cache'      => FALSE, //Kohana::$environment === Kohana::PRODUCTION,
        /**
         * The UID for media files.
         * This should be unique across the entire project because from a css file
         * you want to be able to use relative paths to images.
         * Your css file would not know where an image is if it had a UID of its own.
         * App versions and repository revisions are good UIDs to use.
        */
        'uid' => NULL, // Replace this later - needs to get passed into app to change paths there too.
        // 'uid' => "3-0-dev",
        // Where to upload media files eg. images. Take note of the trailing slash.
        // This should be in the Document root.
        'media_upload_dir' => APPPATH.'media'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR,
        // Width to be used to resize the image to a medium size
        'image_medium_width' => 800,
        // Height to be used to resize the image to a medium size. NULL by default
        // so the image's aspect ratio is maintain when resizing it.
        'image_medium_height' => NULL,
        // Width to be used to resize the image to a thumbnail size
        'image_thumbnail_width' => 70,
        // Height to be used to resize the image to a thumbnail size. NULL by default
        // so the image's aspect ratio is maintain when resizing it.
        'image_thumbnail_height' => NULL,
        // Maximum file upload size in bytes. Remember this figure should not be larger
        // than the maximum file upload size set on the server. 1Mb by default.
        'max_upload_bytes' => '1048576',
);

#11

I’m Having the same problem, I’m running the docker with nginx with ushahidi version 3.7.

The server just can’t load the images.

Is there a trick thing in my architecture, I’m running Ushahidi v3.7 with NGINX in docker behind another NGINX reverse proxy that also do the SSL stuff… could that be some kind of problem.

For the reference, I’m using the https://github.com/ushahidi/platform-release .

Does anyone knows a solution to this problem?


#12

Hey guys, I think I’v may found the source of this problem, have registered in https://github.com/ushahidi/platform-release/issues/5 ,

I’ve inspected that the web interface is trying to reach images in the wrong URL, in my case:
http://mapa.tonarede.org.br/media/upload
that URL returns a blank page, but when I change the URL to https://mapa.tonarede.org.br/platform/media/upload… then the images appear just right…

so I’m thinking it may be some miss URL config problem, and then again, when I access the API URL via https://mapa.tonarede.org.br/platform/api/v3/config/features it returns:
“{
“count”: 3,
“results”: [
{
“id”: “features”,
“url”: “http://mapa.tonarede.org.br/api/v3/config/features”,
“views”: {…”

You can see the url attribute is wrong…
could you guys confirm if you’re getting the same results?

Other, I’ve tried to change the URL in database.config table and in .env BACKEND variable, still the URL for API doesn’t change… any ideias?


#13

Please see https://github.com/ushahidi/platform-release/issues/5#issuecomment-321577068

I’m going to look into updating that docker build process


#14

Fantastic!
Worked just fine!
Thanks @davidlosada!


#15

Hello,
Did you manage to solve it? I also followed the same steps as indicated and the images are broken, but saved on a disk.


#16

Hi @devdh ,

the fix of adjusting the base_url in config/init.php detailed in the github link above should work for you, if you’ve got your platform API installed under a folder and not at the root path of your domain (i.e. www.mysite.com/platform )

Hope this helps!


#17

Unfortunately, this didn’t seem to solve my problem. I wonder if I use a docker instead hmmm cc: @devdh