Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: valid_referers & https
On Mon, Feb 15, 2010 at 02:32:55PM +0200, Elifan wrote:
> server {
> listen xx.xx.xx.xx:80;
> listen xx.xx.xx.xx:443;
>
> ...
>
> location ~* ^.+\.(jpg|jpeg|gif|png|ico) {
>
> valid_referers domain.com *.domain.com none;
> if ($invalid_referer) {
> return 403;
> }
>
> ...
> }
>
>
> При обращении к сайту через http картинки показываются, а если через
> https то вместо картинок отдается 403..
> Я что-то упустил или функция valid_referers не работает в https ?
> Версия nginx из 0.7 и 0.6
Патч.
--
Игорь Сысоев
http://sysoev.ru
Index: src/http/modules/ngx_http_referer_module.c
===================================================================
--- src/http/modules/ngx_http_referer_module.c (revision 2770)
+++ src/http/modules/ngx_http_referer_module.c (working copy)
@@ -124,18 +124,27 @@
len = r->headers_in.referer->value.len;
ref = r->headers_in.referer->value.data;
- if (len < sizeof("http://i.ru") - 1
- || (ngx_strncasecmp(ref, (u_char *) "http://", 7) != 0))
- {
- if (rlcf->blocked_referer) {
- goto valid;
+ if (len >= sizeof("http://i.ru") - 1) {
+ last = ref + len;
+
+ if (ngx_strncasecmp(ref, (u_char *) "http://", 7) == 0) {
+ ref += 7;
+ goto valid_scheme;
+
+ } else if (ngx_strncasecmp(ref, (u_char *) "https://", 8) == 0) {
+ ref += 8;
+ goto valid_scheme;
}
+ }
- goto invalid;
+ if (rlcf->blocked_referer) {
+ goto valid;
}
- last = ref + len;
- ref += 7;
+ goto invalid;
+
+valid_scheme:
+
i = 0;
key = 0;
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://nginx.org/mailman/listinfo/nginx-ru
|