AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[http-status-code-404](server)

Martin Hope
Paul
Asked: 2022-01-07 12:30:41 +0800 CST

提供 404 响应是否有技术要求?

  • 0

是否有提供 404 响应的技术要求(例如 RFC)?

或者如果未找到的请求被丢弃或回复为空,是否会出现其他问题?

http-status-code-404
  • 0 个回答
  • 68 Views
Martin Hope
Laughing Laugh wwwwwww
Asked: 2021-12-08 01:52:38 +0800 CST

无法访问我的网站

  • 0

每个人!我是 linux 爱好者,我对 debian VPS 上的 nginx 有疑问。直到最近我可以访问我的静态网站,但现在我不能。

这是我的用户名sites-available/example在哪里example:

server {
        listen 80 ;
        listen [::]:80 ;
        server_name example.com ;
        root /var/www/example ;
        index index.html index.htm index.nginx-debian.html ;
        location / {
                try_files $uri $uri/ =404 ;
        }
}

sites-available/example有符号链接sites-enabled

我的nginx/error.log:

2021/12/07 08:57:02 [notice] 7383#7383: signal process started
2021/12/07 09:22:00 [notice] 2195#2195: signal process started

在signal process started我遇到 403 或 404 错误之前:

2021/12/05 17:53:05 [emerg] 12400#12400: open() "/etc/nginx/sites-enabled/mail" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2021/12/05 17:55:01 [emerg] 12415#12415: open() "/etc/nginx/sites-enabled/mail" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2021/12/05 18:02:33 [emerg] 12468#12468: open() "/etc/nginx/sites-enabled/mail" failed (2: No such file or directory) in /etc/nginx/nginx.conf:62
2021/12/05 18:05:15 [error] 12522#12522: *1 directory index of "/var/www/mail/" is forbidden, client: 212.16.10.194, server: mail.example.com, request: "GET / HTTP/1.1", host: "example.com"
2021/12/05 18:07:45 [error] 12562#12562: *1 directory index of "/var/www/mail/" is forbidden, client: 212.16.10.194, server: mail.example.com, request: "GET / HTTP/1.1", host: "example.com"

我什至重新安装了 nginx,但我仍然无法访问我的网站。我应该怎么做或在哪里搜索信息来解决这个问题?

sudo ss -tnlp|grep :80显示了这一点:

LISTEN 0 128 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=2524,fd=6),("nginx",pid=2522,fd=6))

LISTEN 0 128 [::]:80 [::]:* users:(("nginx",pid=2524,fd=7),("nginx",pid=2522,fd=7))

debian nginx http-status-code-404 http-status-code-403
  • 1 个回答
  • 188 Views
Martin Hope
ThatCoolCoder
Asked: 2021-07-25 23:29:22 +0800 CST

为什么 Apache2 找不到我的 WSGI 应用程序?

  • 2

在我之前的问题中,我询问了如何让 mod_wsgi 使用特定的 Python 版本。根据该问题的答案,我创建了一个 Python 3.9 虚拟环境并让 WSGI 使用它。但是,现在我的 Flask 应用程序根本没有运行——我只是为我的站点的其余部分配置了 404 页面。重新启动 Apache2 时我没有收到任何错误,当我访问该站点时 Apache 错误日志为空。我认为错误一定是由于我的虚拟环境造成的,因为我在使用相同的配置样式之前已经创建了以前的测试 Flask 应用程序。

我的虚拟环境位于path/to/my/app/venv/.

path/to/my/app/runner.wsgi:

import sys

# Make something appear in error log if the WSGI is run at all
raise ValueError()

PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, PROJECT_DIR)

from my_app import app as application

部分/etc/apache2/sites-available/000-default-le-ssl.conf:

WSGIDaemonProcess myapp user=www-data group=www-data threads=4 python-home=/path/to/my/app/venv/
WSGIScriptAlias /my-app/ path/to/my/app/runner.wsgi

/etc/apache2/mods-available/wsgi.load

LoadModule wsgi_module "/path/to/my/app/venv/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so"
WSGIPythonHome "path/to/my/app/venv"

操作系统:Ubuntu 18.04.5 LTS

mod-wsgi python http-status-code-404 apache2 flask
  • 2 个回答
  • 447 Views
Martin Hope
SBO
Asked: 2021-07-06 22:36:04 +0800 CST

IIS 10 URL 重写给出 404 错误

  • 1

我目前坚持我的重写规则,我需要一些关于它的提示。

情况是这样的:我们有两个网站,一个是 website.com,另一个是 website-staging.com(这里只是示例)

在 website.com 上,对于某些 url,我想使用重写规则来访问暂存网站并显示结果。

这是 web.config 文件中的规则:

<rule name="RewriteSearchQueries" patternSyntax="Wildcard" stopProcessing="true">
<match url="search?*" />
<action type="Rewrite" url="https://website-staging.com/{R:0}" logRewrittenUrl="true" />

我做了模式测试,一切正常。用于重写的 URL 工作正常,但是当我点击 website-staging.com/search?arg=1&blabla=2 时,我收到 404 错误消息:

404 - 找不到文件或目录。您要查找的资源可能已被删除、名称已更改或暂时不可用。

我也尝试采取以下措施:

<action type="Rewrite" url="https://website-staging.com/search?{R:1}" logRewrittenUrl="true" />

它也没有工作。有什么线索吗?

编辑:应用程序请求路由已安装,代理已启用。

iis rewrite http-status-code-404 iis-10
  • 1 个回答
  • 1820 Views
Martin Hope
Dave
Asked: 2021-04-13 17:28:42 +0800 CST

为什么 Apache 服务器在以前工作时在子文件夹上返回 404

  • 0

我刚刚在我的 Apache Ubuntu 服务器上安装了一些来自 GoDaddy 的新 SSL。

然后我通过 SSH 重新启动,一切看起来都很好。

根站点(wordpress 安装)现在可以通过 https 正常加载。

但是,/app 目录中还有另一个 HTML 站点,它返回 404。

这是以前的工作。我没有更改任何配置文件。

有任何想法吗?

ubuntu php wordpress http-status-code-404 apache2
  • 1 个回答
  • 455 Views
Martin Hope
user9927059
Asked: 2021-02-02 04:37:37 +0800 CST

Nginx - 以前加载时未找到某些资源

  • 1

我刚刚遇到了一个非常奇怪的问题。我在我的网站和 svg 中使用的一些字体没有加载,而昨天一切正常。我最近所做的唯一更改是一些重写以删除扩展名。

每个路径都是正确的,并且主nginx.conf文件包含include /etc/nginx/mime.types; 再次,昨天一切正常。

这是我的配置文件,这是我唯一更改的内容。


server {
    listen 80;
    listen [::]:80;
    
    server_name mysite.app;
    
    rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
    rewrite ^/(.*)/$ /$1 permanent;

    root /var/www/html/;
  
    index index.php index.html index.htm index.nginx-debian.html;
       
    location / {
        #try_files $uri $uri.html $uri/ @extensionless-php;
        try_files $uri/index.html $uri.html $uri/ @extensionless-php;
    }

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
                expires 365d;
        }

    location ~*  \.(pdf)$ {
                expires 30d;
        }
    
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    
        if ($request_uri ~ ^/([^?]*)\.php$) { 
             return 307 /$1; 
        }
        
        if ($request_uri ~ ^/([^?]*)\.php(\?+)) { 
             return 302 /$1?$args; 
         }
    }

    location @extensionless-php {
            rewrite ^(.*)$ $1.php last;
    }   

    location ~ /\.ht {
        deny all;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mysite.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    listen 443 ssl http2; # managed by Certbot
    server_name www.mysite.app;
    ssl_certificate /etc/letsencrypt/live/mysite.app/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.app/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    return 301 https://mysite.app$request_uri;
}

server {
    if ($host = www.mysite.app) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80 ;
    listen [::]:80 ;
    server_name www.mysite.app;
    return 404; # managed by Certbot
}

运行curl -IL <resource_location>时出现HTTP/1.1 404 Not Found错误。

nginx http-status-code-404
  • 1 个回答
  • 165 Views
Martin Hope
Paul Fan
Asked: 2020-10-29 21:41:21 +0800 CST

我的 Magento 只能加载第一个首页,所有页面都是 404。 Nginx 服务器配置问题

  • 0

我正在尝试在 WSL、ubuntu Nginx 网络服务器、localhost 上运行 Magento 2 我只能加载我的网站第一个首页,但其余页面找不到 404。我只修改 /etc/nginx/sites-available/default 文件。因为我使用的是 localhost 并且只有 1 个站点。我想我不需要创建另一个。谁能帮我看看我的配置文件有什么问题?/etc/nginx/sites-available/默认。我对 Nginx 不熟悉,我确实尝试了 google 很多天,仍然找不到任何解决方案。

如果有人可以提供帮助,我将不胜感激。

  # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html/Magento2_PAUL;

        # Add index.php to the list if you are using PHP
        index index.php;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # proxy_pass http://localhost:8080;
                # proxy_http_version 1.1;
                # proxy_set_header Upgrade $http_upgrade;
                # proxy_set_header Connection 'upgrade';
                # proxy_set_header Host $host;
                # proxy_cache_bypass $http_upgrade;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
         include snippets/fastcgi-php.conf;
        #
        #       # With php7.0-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php7.0-fpm:
               fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#              try_files $uri $uri/ =404;
#       }
#
magento nginx http-status-code-404 windows-subsystem-for-linux
  • 1 个回答
  • 97 Views
Martin Hope
SteveFerg
Asked: 2020-06-11 09:51:24 +0800 CST

在我的网站上不断进行机器人探测

  • 0

从 Godaddy 查看我的 IIS 日志,我每天会收到数百个 404 错误,其中一些脚本小子或机器人一直在寻找漏洞或要利用的页面/目录。除了大量的目录搜索尝试和不存在的 php 页面外,我还看到在各种目录中对名为“.env”的文件进行的探测次数异常多。有谁知道这个文件是用来搜索什么的?

website iis asp.net http-status-code-404
  • 1 个回答
  • 196 Views
Martin Hope
Pithikos
Asked: 2020-05-22 01:53:53 +0800 CST

从 Nginx 中的远程服务器返回带有状态码的文件

  • 0

我正在尝试通过让 nginx 在响应之前对资源进行回查,将我的 SPA 设置为针对无效资源返回 404。所有这些都是为了避免带有 200 的无效页面,从而让蜘蛛爬取软 404 页面。

我想要的行为

Browser                           Nginx                           API
  | -- GET myapp.com/users/12 -->   |                              |
  |                                 | -- GET myapi:8000/users/12   |
  |                                 |   <----------- 404 --------  |
  | <-- 404 index.html ------------ |
  |                                 |

我希望我的配置如下所示

server {
        listen       80;
        server_name  localhost;
        root   /usr/share/nginx/html;
        index  index.html;

        location /users/ {
          # 1. Fetch from myapi:8000
          # 2. Return index.html with status from fetched URI
        }
}

我已经研究了一段时间,但我对如何实现这一点有点迷茫。我已经看到了很多简单的例子try_files等等,但似乎没有什么适合我的情况,因为似乎大多数例子都是非常简单的转发。

我怎样才能实现上述行为?

nginx http-status-code-404 reverse-proxy http-status-code
  • 1 个回答
  • 396 Views
Martin Hope
Prisoner
Asked: 2020-05-18 01:34:55 +0800 CST

找不到远程error_page时如何使用本地error_page?

  • 2

我正在尝试为我的 error_page 创建一个后备。基本上,逻辑应该如下所示:

  1. 加载 foobar.html
  2. 远程服务器上不存在 -> 从远程服务器加载 404.html 以显示 404 页面
  3. 远程服务器上不存在 -> 在本地文件系统上加载 404.html

加载两者localhost/404.html并localhost/global404.html正常工作,但是当我中断localhost/404.html(通过从 http 服务器中删除文件)时,它不会global404.html像我期望的那样显示页面。

server {
    listen 80;
    server_name example.com www.example.com;
    proxy_intercept_errors on;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        error_page 404 /404.html;
    }

    location /404.html {
        proxy_pass http://localhost:3000/404.html;
        error_page 404 /global404.html;
    }

    location /global404.html {
        root /usr/share/nginx/html;
    }
}

当我点击时,上面的工作正常http://localhost/404.html(当 404.html 文件位于远程服务器上时,它显示,当我删除文件时,它会加载 global404.html 文件)。

但是,当我键入一个不存在的页面时,我只会得到默认的 nginx 404 页面。

nginx http-status-code-404
  • 1 个回答
  • 449 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve