使用nginx的静态内容域在尝试访问静态文件时给我一个错误

作为标题说,我试图服务我的静态内容形成另一个域名托pipe在同一台服务器上使用nginx

这是我的服务器configuration:

server { listen 80; server_name static-sexparken.nu; rewrite ^ http://static-sexparken.nu$uri permanent; } # the server directive is nginx's virtual host directive. server { # port to listen on. Can also be set to an IP:PORT listen 80; # Set the charset charset utf-8; # Set the max size for file uploads to 10Mb client_max_body_size 50M; # sets the domain[s] that this vhost server requests for server_name static-sexparken.nu; # doc root root /var/www/static-sexparken.nu/public; # vhost specific access log #access_log /var/log/nginx_access.log main; # Set image format types to expire in a very long time location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ { access_log off; expires max; } # Set css and js to expire in a very long time location ~* ^.+\.(css|js)$ { access_log off; expires max; } # Catchall for everything else location / { root /var/www/sexparken.nu/public; access_log off; index index.html index.shtml; expires 1d; #try_files $uri $uri/404.html; if (-f $request_filename) { break; } } location ~* ^/(pkg|rpms)/ { autoindex on; } error_page 500 502 503 504 /500.html; error_page 404 /404.html; } 

当我尝试直接访问域上的图像时会发生什么,我得到:

如果您被禁用或拒绝接受Cookie,则有时会出现此问题。

从Firefox作为一个错误。 从网站上也正确地链接了这些,我什么也得不到。

这里可能是什么问题? 任何帮助赞赏。

当你启动nginx时,你应该得到一个重复的服务器名称警告。 两个服务器块都匹配相同的主机名,并使用第一个,因为它是第一个。 你告诉它redirect到相同的主机名,所以它永远循环。 也许你打算添加一个www。 到那第一个server_name?