After adding the hotlinking protection code to the server block, none of the images now loads. Here is the complete server block code of the web server in question:
server {
listen 443 ssl;
server_name mydomain.com www.mydomain.com 192.168.1.101;
if ($host !~* ^www\.(.*)$) {
return 301 https://www.$host$request_uri;
}
ssl_certificate "G:/Web Sites/MyDomain/certificate/certificate.crt";
ssl_certificate_key "G:/Web Sites/MyDomain/certificate/private.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
charset utf-8;
access_log logs/MyDomain.log main;
root "G:/Web Sites/MyDomain";
index index.php index.php3 index.php4 index.php5 index.html index.htm;
location / {
location = /favicon.ico {
log_not_found off;
access_log off;
}
if ($request_uri ~* ".(ico|css|js|gif|jpe?g|png)$") {
expires 30d;
access_log off;
add_header Pragma public;
add_header Cache-Control "public";
break;
}
}
error_page 404 /; #404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root "G:/Web Sites/MyDomain";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#Hotlinking protection.
#location ~* \.(gif|jpe?g|png|wmv|avi|mpg|mpeg|mp4|htm|html|js|css)$ {
# valid_referers none blocked mydomain.com *.mydomain.com ~\.google\. ~\.yahoo\. ~\.bing\. ~\.facebook\. ~\.fbcdn\. ~\.twitter\. ~\.pinterest\. ~\.ask\. ~\.wp\.;
# if ($invalid_referer) {
# return 301 https://sites.google.com/site/tcperpetual/home/hotlinked-message.gif;
# }
#}
}
Not too sure what is wrong or if my images have some other referer, but they are all on my web server. My images are dynamically loaded into a div.