答复: static images 404 on Windows

kevin whyork at gmail.com
Tue May 12 13:42:48 MSD 2009


Hi 坏人(Bad guy),
I had translated you mail. Hope it'll help you.


麻烦把你的各种信息发出来
Please send all you configuration detail to me.
包括主目录、各种静态文件的目录结构、以及说明下fastcgi实现的方式。
Including the webroot directory, static files and directory structure, and try to introduce your fastcgi solution.

我的部分配置。基于centos+nginx+apache+php
Hereby my configuration file, based on centos+nginx+apache+php
	server { 
		listen       80;
		server_name  www.abc.com;
		index index.htm index.php;
		root /data/sites;

		location ~* ^.+\.(jpg|jpeg|gif|png|js|css|swf)$ {
			valid_referers none blocked server_names *.abc.com;
			if ($invalid_referer) {
				return   403;
			}
			expires 1d;
			add_header	X-Cache   HIT;
			root         /static/abc;
		}


		location / {
			proxy_pass	http://127.0.0.1:81;
			proxy_redirect	off;
			proxy_set_header	isme		"huairen";
			proxy_set_header	Host		$host;
			proxy_set_header	X-Real-IP		$remote_addr;
		}

主目录和静态文件可以相同可以不同,diy很强。还可以用try_files的方式
You can the root directory could be same policy, it’s easy to manipulate, you can try using "try_files" method also.


静态在上面,动态在下面。推荐用X-Real-IP,否则ip就有被人为伪造的可能
Keep the static file policy first, the dynamic request policy below. I suggest using the "X-real-IP" parameter instead of "x-forward-to". Because the "X-forward-to" is easily to fake.

X-Cache是我的习惯,你可以忽略。删掉可以减少几字节,哈哈
I'm used to append  "x-cache" header to the response in order to mark this request was hit in cache , you can do it in your way. Delete this line will not cause any subsequences.

我没用fastcgi,你相应的改下就行
I am not using fastcgi solution, you can change it in your way, that fine.

(以上部分配置是从我的一个站点中截取出来的,基于nginx+perl。因内核改了很多,所以不可能全发出来,见谅)
(The configuration I provided is a section from my own site. Based on nginx + perl. I have modified quite a lot of core source of nginx, please forgive me that I can't publish all details of my configuration for security concern)

btw:you should learn more foreign languages. for better use of nginx, i even had self-russian

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,1888,1945#msg-1945

BD,
Kevin


More information about the nginx mailing list