New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
NGINX Rewrite Rules
Hi All,
I started noticing few of the image host are redirecting the hotlinked images to the different page where they can be shown with ads
But I do also notice
1) they are properly shown on the embeds, if the images are linked in some forums like LET then wont it be a problem when we have such redirect rules?
2) they are redirecting on only second visits if I am not wrong.
Example: The below image is hotlinked
But if you try to open in new browser it will redirect.
Can this be achieved by doing simple redirect?
Like I want to convert
https://s1.im.ge/2021/05/30/oHS.png
https://s1.im.ge/2021/05/30/oHS.th.png
https://s1.im.ge/2021/05/30/oHS.md.png
to
Comments
Im not entirely sure what you're trying to achieve. Your example desired url seems backwards
That being said. The nice "preview" display you see inline in forum and social media posts is typically a product of requester IP or headers from when the forum first fetches the link. There's some open standards to provide preview exchange.
Anyway i think you'd more likely need to be using rewrites and possible additional headers and reverse proxying rather than redirect
I am trying to achieve the same what post image is doing, but post image do much more as they are totally changing the url to different
https://i.postimg.cc/fbV5PK9Y/clown-on-computer.jpg to https://postimg.cc/CZVjBbJK
Where as I am just trying to redirect
https://s1.im.ge/2021/05/30/oHS.png
https://s1.im.ge/2021/05/30/oHS.th.png
https://s1.im.ge/2021/05/30/oHS.md.png
to
https://im.ge/i/oHS
You can see similarities from url and then in the too url. But my doubt, if a rewrite rule is written for that, will it break the embed functionality used in forums.
its not a rewrite, just a simple redirect based on the Accept header.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
If you have a cache like Cloudflare in front, make sure to set the set the Vary header too.
so the changes needs to be done on the nginx config file right? If thats the case, I can hire some one who can do the rules setup for me.
If I am not wrong, rewrite rules do the redirect right.
regex pattern:
https://regex101.com/r/BPmRn2/1
rewrite :
Can you give the rewrite rules for this which works on nginx
https://s1.im.ge/2021/05/30/oHS.png
https://s1.im.ge/2021/05/30/oHS.th.png
https://s1.im.ge/2021/05/30/oHS.md.png
to
https://im.ge/i/oHS
And still if some people use embeds of those direct link on forums, it needs to work.
After using the redirects, the above images still needs to get displayed as they are used as embed.