Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Shells Virtual Desktop
BMail.ag - Secure Email Service
Server.net
CPLicense.net
VPS Server
Buy VPN
Vultr
VMs for AI
HostDare
HostDare
ReliableSite White-Label Dedicated Hosting for Resellers
InterServer VPS
BMail.ag - Secure Email Service
Best VPN
High-Performance Bare Metal Server Solutions
Karvl.com
Server Mania Cloud Hosting
DataWagon Hosting
AlphaVPS Hosting
Evoxt.com
Clouvider
VPS Hosting with NVMe
Residential IPs in the US & 4G Mobile Proxies in EU & US with Unlimited Bandwidth
ReliableSite White-Label Dedicated Hosting for Resellers
Rabisu - Hosting Solutions
Shells Virtual Desktop

In this Discussion

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.

How to prevent redirect if image is embedded?

I currently have setup to redirect if a user direct access the image by browser. However I do not want to redirect if a image is embedded on the page using <img src=""/>

this is my nginx conf

location ~ "^/c/600x1200_90_webp/img-master/img/\d+/\d+/\d+/\d+/\d+/\d+/((?<filenum>\d+)[^/]+\.(jpg|png|webp))$" {
proxy_pass http://xxx.xxx.xxx.xxx:8081;
valid_referers server_names;
if ($invalid_referer = "1") {
return 301 http://example.com/detail?id=$filenum; }
}

How can I fix this?

Comments

  • jmgcaguiclajmgcaguicla Member
    edited February 2022

    In the spirit of not being a Stack Exchange cucklord who will explain why X is better than Y instead of answering the question:

    Instead of checking for valid referrers (via server_names), you should just be checking against blank referrers. A request from an embed usually™ has a non-empty Referer header as opposed to a direct link.

    Again, this is not water-tight as people can just spoof but I'm assuming you just need a "works most of the times" solution so here you go.

    Thanked by 1bulbasaur
Sign In or Register to comment.