News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Re: SMF 2.0.15 proxy.php

Started by epikurieu, February 23, 2018, 10:10:21 AM

Previous topic - Next topic

epikurieu

Hi, I have the same problem of images not showing on my forum after installing an SSL certificate.
I read quite extensively all threads on the subject and tried all solutions and patches that were submitted, but none of them worked.
So I switched back to the file included in 2.0.15 upgrade pack, and disabled image proxy until I find a solution.

The forum is here : https://www.neuronesconnection.fr/

Here is an example of an url that is called when the image proxy is enabled : https://www.neuronesconnection.fr/proxy.php?request=http%3A%2F%2Fwww.neuronesconnection.fr%2Fimages%2Fjeux%2Fcine%2F060.jpg&hash=30312a1598c442c739750f80b1d43464
It seems to be an encoding issue, am I wrong ?

tinoest

Encoding is fine, I think its more likely it's requesting it against your own site.

You need to change your own site to be https, not just the forum.

The url you posted was; https://www.neuronesconnection.fr/images/jeux/cine/060.jpg I believe.

epikurieu

What do you mean by "requesting it against my own site" ? (Sorry, I'm French.)

There's nothing else on my (shared) hosting, the forum is at the root.

What I see now is that there's no "S" after the "http" in the request : is that part of the problem ?

epikurieu

By the way, the problem occurs with images posted before the transition (with an uploading tool, directly on the server), or images that are/will be hosted elsewhere by the users, on non-https sites.

So with the url you give it's fine, but it's not that one that was used on the original post. (I hope what I'm saying makes sense to you.)

tinoest

Quote from: epikurieu on February 23, 2018, 10:36:56 AM
By the way, the problem occurs with images posted before the transition (with an uploading tool, directly on the server), or images that are/will be hosted elsewhere by the users, on non-https sites.

So with the url you give it's fine, but it's not that one that was used on the original post. (I hope what I'm saying makes sense to you.)

I mean that the link you tried to proxy was to the same url as your website. Which then redirected you to the https version.

I would try and update all those links to https. I'm not sure if SMF has a way to up date existing posts to https from http mind.

The ones on other sites should be fixed by the changing the code as mentioned here https://www.simplemachines.org/community/index.php?topic=553914.msg3926081#msg3926081


epikurieu

OK then, the proxy is only meant for images hosted on other websites? I could have tried for a long time without success, I didn't understand correctly its purpose! :laugh:

Thanks, I'll try the fix you mention.

epikurieu


tinoest

Just to confirm the url is this; http://www.lapassiondubois.com/images/stories/enfance/p1030429.jpg

Does the image show on the second load of the page?

Just checked this and making the change to
                return file_put_contents($dest, json_encode(array(
                        'content_type' => $headers['content-type'],
                        'size' => $response['size'],
                        'time' => time(),
                        'body' => base64_encode($response['body']),
                ))) === false ? false : true;


fixes the issue for me with that image you linked to.

epikurieu

Yes the url is right.

The image never shows (as long as the proxy is enabled), even after CTRL + F5.

Just to be sure: those lines of code are supposed to be on the file proxy.php, at the root of the forum, right? Nearly at the end of the file, ~line 192?

The file in the 2.0.15 upgrade pack has this, it didn't work; so I tried to put back the file I had until I changed to https, and modified the lines like said => still not working... :-\

tinoest

Mine looks like the attached.

I checked it with the image you put on here and it worked ok. Settings were the same as you mentioned.

butch2k

Did you u use my proxy code or the default one ? Try mine, not sure it'll corect your issues but its error handling is better than the one on the original file.

epikurieu

Quote from: butch2k on February 23, 2018, 02:00:54 PM
Did you u use my proxy code or the default one ? Try mine, not sure it'll corect your issues but its error handling is better than the one on the original file.

I think I used every single version that was posted! ;) Are you talking about this one: https://www.simplemachines.org/community/index.php?topic=558395.msg3958115#msg3958115 ?
I also tried it, yes.

Quote from: tinoest on February 23, 2018, 01:57:56 PM
Mine looks like the attached.

I checked it with the image you put on here and it worked ok. Settings were the same as you mentioned.

Still not working with your file.

Could it be some setting in the php configuration of the hosting? Something in my .htaccess? A conflict with a mod? The configuration of the cache (in /area=serversettings;sa=cache - Mine is on "level 1")?

epikurieu

I noticed that when I edit a message in which I posted an image with a simple url (like http://www.lapassiondubois.com/images/stories/enfance/p1030429.jpg), the url is now the proxied one. Is that the expected behavior?

tinoest

#13
Quote from: epikurieu on February 23, 2018, 02:17:16 PM
Could it be some setting in the php configuration of the hosting? Something in my .htaccess? A conflict with a mod? The configuration of the cache (in /area=serversettings;sa=cache - Mine is on "level 1")?

Mine is also Level 1, can you provide a link to a thread with a image in it?

I think your proxy is not returning the data type for some reason so the browser can't render it.

Actually try the attached file, it might work...

epikurieu

On this thread there are images that show because they are https (located on another server), and some that don't: all http, some on my server, some on other ones.
https://www.neuronesconnection.fr/cinema/cine-en-images/

Unfortunately, your file didn't fix it either.

Anything to do with pretty urls ?

butch2k

proxy.php is doing its job correctly, sending back the file.
At one point it checks the content_type and exit if it's not an image, so we can be pretty sure the data as seen by the proxy script is an image and the proper content type is sent back yet...
$contentParts = explode('/', !empty($cached['content_type']) ? $cached['content_type'] : '');
if ($contentParts[0] != 'image')
exit;

header('Content-type: ' . $cached['content_type']);


... the response header content-type is "content-type:text/html; charset=UTF-8", so my 2 cents is that there is some kind of header override at one point which basically says "if file is .php then content type is text/html".

Could you check your apache configuration ?

epikurieu

I'm on a shared hosting so I don't know how to access that information (if I can at all).

Here is the phpinfo: https://www.neuronesconnection.fr/phpinfo.php and a screenshot of the php.ini is attached. I use php 5.6.

albertlast

Well you could try to remove the header from the webserver before you set the from proxy:

header_remove('content-type');

Should be placed in front of the line where the content-type is set by proxy.php

butch2k

Unfortunately the content-type is most likely added by the webserver at the time the request is sent back to the client, so it probably won't work.  :(

Check for existence of an .htaccess file a the root of your website.

albertlast

When this not help,
maybe he should try to match the same case like the webserver does.
proxy does Content-type
webserver does content-type
when he match the same case maybe the webserver doesn't try to add a different one.

Advertisement: