<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">I found the reason!</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">I have check and my files and folders
are already with rights: 0755 for folders and 0644 for files.<br>
<br>
I checked also the owner of the website and unfortunately I did
some test and did not resolved the issue.<br>
<br>
I have put a file aaa.jpg on my website root folder:<br>
<br>
Locally this code is working fine:<br>
<br>
list($imageWidth, $imageHeight) =
getimagesize('<a class="moz-txt-link-freetext" href="http://local-mywebsite.com/aaa.jpg">http://local-mywebsite.com/aaa.jpg</a>');<br>
echo $imageWidth;<br>
<br>
So I change the code to:<br>
<br>
list($imageWidth, $imageHeight) =
getimagesize('<a class="moz-txt-link-freetext" href="https://mywebsite.com/aaa.jpg">https://mywebsite.com/aaa.jpg</a>');<br>
echo $imageWidth;<br>
<br>
and I get the error:<br>
2021/08/04 11:33:00 [error] 2196869#2196869: *388196 FastCGI sent
in stderr: "PHP message: PHP Warning:
getimagesize(<a class="moz-txt-link-freetext" href="https://mywebsite.com/aaa.jpg">https://mywebsite.com/aaa.jpg</a>): failed to open
stream: HTTP request failed! HTTP/1.1 403 Forbidden<br>
<br>
I change the right to 0777 to file and still have the 403.<br>
<br>
I changed the owner of the file aaa.jpg to www-data and changed
the owner of the website root folder to www-data as well but still
have the 403.<br>
<br>
On /etc/nginx/nginx.conf file I have:<br>
user www-data;<br>
<br>
I didn't know where to look at!<br>
<br>
And unexpectedly I remembered that yesterday I added some rules to
nginx to block bad bots. Which I didn't do locally.<br>
<br>
I added this configuration rules:<br>
<a moz-do-not-send="true"
href="https://github.com/mitchellkrogza/nginx-badbot-blocker">https://github.com/mitchellkrogza/nginx-badbot-blocker</a><br>
<br>
And took a look at it and notified this rules:<br>
<br>
## Add here all hosts that should be spared any referrer checking.<br>
## Whitelist all your own IPs in this section, each IP followed by
a 0;<br>
geo $bad_referer {<br>
127.0.0.1 0;<br>
111.111.111.111 0;<br>
}<br>
<br>
I added the comment for 127.0.0.1 and it's now working fine. <br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">What is the line 111.1111.111.111 0 for
?</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Do you have any advise on this rules
added from <a class="moz-txt-link-freetext" href="https://github.com/mitchellkrogza/nginx-badbot-blocker">https://github.com/mitchellkrogza/nginx-badbot-blocker</a>
?</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Thanks :)<br>
<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<div class="moz-cite-prefix">Le 03/08/2021 à 21:14, Vincent M. a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:4f3ad3b5-e780-f1df-4697-0b2abaf954f9@free.fr">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p><font face="Arial">Hello all,</font></p>
<p><font face="Arial">I have a 403 error when trying to use the
PHP function getimagesize on nginx based web server:<br>
<br>
list($imageWidth, $imageHeight) =
getimagesize($imagesSource['Main']);</font></p>
<p><font face="Arial">Where $imageSource['Main'] is like:<br>
<br>
<a class="moz-txt-link-freetext"
href="https://mywebsite/include/php/render/canvas/VR/2/image/U35p/ver//bgColor/ffffff/widthMM/300/heightMM/388/aube-sunny.jpg"
moz-do-not-send="true">https://mywebsite/include/php/render/canvas/VR/2/image/U35p/ver//bgColor/ffffff/widthMM/300/heightMM/388/aube-sunny.jpg</a></font></p>
<p><font face="Arial">It's an image generated by PHP-imagick
module and is not locally available. This image can be opened
by a browser with no problem.<br>
<br>
To generate this image which go through 404. Nginx is
configured like that:<br>
<br>
error_page 404 = /url_rewriting.php;<br>
And in the file url_rewriting.php, we analyse the URL to see
if it's real 404 or an image which must be generated:<br>
<br>
if((isset($urlHash[2]) && $urlHash[2] === 'render')) {<br>
...<br>
header('Status: 200 OK', false, 200);<br>
chdir('include/php/render/'.$_GET['render']);<br>
require
('include/php/render/'.$_GET['render'].'/render_img.php');<br>
exit;<br>
}<br>
All is working fine but not the getimagesize from my own
server.<br>
<br>
What is strange is that it's working fine on my development
environment which has the same versions of nginx and PHP and
pretty the same configuration.<br>
<br>
It might a configuration issue or a right issue on a certain
file but I don't know where to check.</font></p>
<font face="Arial">Thank you,<br>
Vincent.<br>
<br>
</font> <br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
nginx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a class="moz-txt-link-freetext" href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
</blockquote>
<p><br>
</p>
</body>
</html>