我从我的供应商那里安装了全新的 VPS(Windows 2008 R2、IIS 7.5)。
默认网站工作正常:http://5.9.251.167/
我创建了一个新网站,并绑定到http://new.ianquigley.com
在该服务器上以及域映射到 IP 地址的其他任何地方。(例如 ping new.ianquigley.com)。
我创建了子文件夹c:\inetpub\wwwroot\com.ianquigley
并创建了一个index.html
内容为“ <html>cake</html>
”的 HTML 文件
该网站的默认文档是 index.html
在服务器上,在 Chrome 中,我浏览到http://new.ianquigley.com/index.html并收到 404 错误。
该页面说;
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had it's name changed,
or is temporarily unavailable.
Detail:
Module: IIS Web Core
Notification: HttpRequestHandler
Handler: StaticFile
Error Code: 0x80007002
Request URL: http://new.ianquigley.com/index.html
Physical path: c:\inetpub\wwwroot\com.ianquigley\index.html
Logon Method: Anonymous
Logon User: Anonymous …
Run Code Online (Sandbox Code Playgroud) 我目前正在使用 1.5dev-17 重新配置 HAProxy。我想做的是在没有后端用于特定请求时返回 404 错误。
我们当前的配置使用 default_backend 路由到我们的 django 应用服务器,但是当有大量探测请求(如笔测试)与其他配置的后端都不匹配时,我们的 django 服务器在尝试时会停止为这些无效请求提供服务,最终返回 404。
我想从 HAProxy 提供 404,而不是委托给 django 后端。我目前正在通过黑客实现这一目标:
frontend www
...
default_backend nomatch
backend nomatch
errorfile 503 /var/www/http/404.http
Run Code Online (Sandbox Code Playgroud)
在 404.http 文件中,我在标题中设置了 404 状态代码。这有效,但感觉非常错误。使用 HAProxy 有没有更好的方法来实现这一点?或者我应该使用常规后端并让它处理 404 响应?
是否可以让 Apache 使用位置标签自动返回单个 URL 的 404 页面?
<Location "/some/url">
# ???
</Location>
Run Code Online (Sandbox Code Playgroud)
首选没有 mod_rewrite 或任何其他模块的解决方案。
我向 ISS 添加了一个 ASP.NET MVC3 站点(在调试器中运行良好)。在浏览器中查看站点时,除了所有 CSS 和 JS 文件都返回 404 之外,一切似乎都运行良好。
这是 IIS 管理器中的站点:
其他详情:
我正在提供 .JSON 文件,但即使该文件存在,当访问任何文件时,IIS 仍会不断抛出 404 错误。我尝试将其中一个文件重命名为 .JS,并且有效。
任何指针什么设置会导致这个问题?
对于我的 NGINX 服务器,我设置了一个虚拟服务器来分发静态内容。目前我正在尝试设置它以便图像具有到期日期。但是,当我为此创建一个位置指令时,一切都会导致 404。
我现在的配置是这样的:
/srv/www/static.conf
server {
listen 80;
server_name static.*.*;
location / {
root /srv/www/static;
deny all;
}
location /images {
expires 1y;
log_not_found off;
root /srv/www/static/images;
}
}
Run Code Online (Sandbox Code Playgroud)
请注意,此文件包含在 /etc/nginx/nginx.conf 中的 http 指令中
我试图访问图像,在,让我们说...... static.example.com/images/screenshots/something.png
。果然,图像也存在于/srv/www/static/images/screenshots/something.png
。但是,转到上述地址不起作用,只是告诉我404 Not Found。
但是,如果我删除location /images
并更改location /
为以下内容...
location / {
root /srv/www/static;
}
Run Code Online (Sandbox Code Playgroud)
有用!我在这里做错了什么?
我最近在切换到 Cloudflare 后遇到了一个问题,解决方案是基本上阻止 Cloudflare 缓存 404 响应。
在我们的负载平衡多服务器设置中,偶尔会发生 404,但它们会被 rsync(通过 lsyncd)快速修复。在 Cloudflare 之前,对 404ed 文件的重新请求将很快变为 200,因为 rsync 完成其工作。
但是,由于 Cloudflare 根据缓存标头缓存所有数据,并且 apache 和 nginx 都不会发送 404 的 no-cache 标头,因此 Cloudflare 最终会缓存 404 响应一段时间。
我一直在寻找一种解决方案,以在 apache 和 nginx(全球范围内,对于所有托管域)中为 404s 全局添加此类标头,但到目前为止还没有找到。
任何人都可以帮忙吗?
谢谢你。
好的,所以我以前没有使用 SSL/HTTPS 的经验,我只处理过标准的 HTTP。最近我开始在一个需要 SSL 的网站上工作。所以当然,我已经出去研究了如何开始。我已经到了成功安装 SSL 证书的阶段 - 出现绿色挂锁,服务器响应端口 443 上的 HTTPS 请求。我遇到的问题是,无论我做什么,我都无法使用 HTTPS/ SSL,但是它们在端口 80/HTTP 上看起来很好(直到我将 HTTP 重定向到 HTTPS)。
简而言之,我完全可以访问 HTTPS 站点,但是我的页面没有被发送,而是为每个请求发送 404。
<VirtualHost *:80>
ServerName [serverName]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
</VirtualHost>
<VirtualHost *:443>
ServerName [serverName]
ServerAdmin [email]
DocumentRoot [docRoot]
# I know the following SSL cert stuff is correct
SSLEngine On
SSLCertificateFile [...]/[domain].crt
SSLCertificateKeyFile [...]/[certificate].key
SSLCertificateChainFile [...]/[theotherone].crt
ErrorLog ${APACHE_LOG_DIR}/[custom]_error.log
CustomLog ${APACHE_LOG_DIR}/[custom]_access.log combined
<Directory "[docRoot]">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order …
Run Code Online (Sandbox Code Playgroud) configuration https http-status-code-404 apache-2.4 raspbian
这个问题的大多数答案是,设置 fastcgi_param SCRIPT_FILENAME 并且它会起作用(斜体格式被破坏了?!)。
我已经设置了这个变量(正确)但它仍然显示错误而不是 404 页面,因为问题的根源在这里:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
Run Code Online (Sandbox Code Playgroud)
一个不存在的路径被传递给 php5-fpm,这反过来打印错误,在日志中看起来像:
FastCGI sent in stderr:
"Unable to open primary script: ... (No such file or directory)"
while reading response header from upstream
Run Code Online (Sandbox Code Playgroud)
所以在该行之前fastcgi_pass
必须有一个条件来检查文件是否真的存在,或者,如果fpm worker返回“file not found”,引导nginx返回404页面。
我怎样才能做到这一点?
我有一些在 IIS 7.5 下运行的 WCF web 服务,它们正确响应 http 请求,但在使用 SSL 调用方法时响应 404(未找到)错误。
该站点的绑定如下:
当调用http://127.0.0.1:8088/Public/PublicDataService.svc 时,我得到了预期的响应:
您已经创建了一个服务。
要测试此服务,您需要创建一个客户端并使用它来调用该服务。您可以使用命令行中的 svcutil.exe 工具使用以下语法执行此操作:等
同样,调用任何 Service 方法都有效,有一个最基本的方法叫做 CanConnect,它只返回“true”
http://127.0.0.1:8088/Public/PublicDataService.svc/CanConnect
真的
使用 https 时,结果如下。
https://127.0.0.1/Public/PublicDataService.svc
您已经创建了一个服务。
要测试此服务,您需要创建一个客户端并使用它来调用该服务。您可以使用以下语法从命令行使用 svcutil.exe 工具执行此操作:
https://127.0.0.1/Public/PublicDataService.svc/CanConnect
“/Public”应用程序中的服务器错误。
无法找到该资源。
描述:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、更改名称或暂时不可用。请检查以下 URL 并确保其拼写正确。
请求的 URL:/Public/PublicDataService.svc/CanConnect
版本信息:Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.6.1055.0
这让我完全被难住了,如何调用 .svc 工作但它的内部方法给出 404?更令人困惑的是,这是有效的……事实上,我什至不确定它何时停止,即它是否对应于代码发布或服务器补丁等。
网站的实际配置是这样的:
Webservices (this is the root of the application / where the Web.Config sits)
- Public (a windows directory, no addition config)
Run Code Online (Sandbox Code Playgroud)
还有许多其他服务直接在根目录下运行,它们在 http 和 https 下都运行良好。 …
iis ×3
nginx ×3
apache-2.2 ×2
https ×2
apache-2.4 ×1
asp.net-mvc ×1
cache ×1
fastcgi ×1
haproxy ×1
http ×1
http-headers ×1
iis-7 ×1
iis-7.5 ×1
php-fpm ×1
raspbian ×1
static-files ×1
virtualhost ×1
wcf ×1
web-server ×1