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
    • 最新
    • 标签
主页 / user-78417

suchislife's questions

Martin Hope
suchislife
Asked: 2025-01-01 02:12:37 +0800 CST

Ubuntu NGINX 1.24.0 不再包含基本身份验证模块。如何启用?

  • 6

我无法在网上找到有关 nginx 从哪个版本开始将其http_auth_basic_module作为配置选项包含的信息。此外,我该如何启用它?或者我可以从哪里下载模块?

服务器配置:

nginx -V

nginx version: nginx/1.24.0 (Ubuntu)
built with OpenSSL 3.0.13 30 Jan 2024
TLS SNI support enabled
./configure \
--with-cc-opt='-g -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/nginx-DlMnQR/nginx-1.24.0=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -fdebug-prefix-map=/build/nginx-DlMnQR/nginx-1.24.0=/usr/src/nginx-1.24.0-2ubuntu7.1 -fPIC -Wdate-time -D_FORTIFY_SOURCE=3' \
--with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-z,now -fPIC' \
--prefix=/usr/share/nginx \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=stderr \
--lock-path=/var/lock/nginx.lock \
--pid-path=/run/nginx.pid \
--modules-path=/usr/lib/nginx/modules \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--with-compat \
--with-debug \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_v2_module \
--with-http_dav_module \
--with-http_slice_module \
--with-threads \
--with-http_addition_module \
--with-http_flv_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_mp4_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_sub_module \
--with-mail_ssl_module \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-stream_realip_module \
--with-http_geoip_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_perl_module=dynamic \
--with-http_xslt_module=dynamic \
--with-mail=dynamic \
--with-stream=dynamic \
--with-stream_geoip_module=dynamic

使用 grep 搜索:

nginx -V 2>&1 | grep http_auth_basic_module

结果:

Not found

GitHub - /src/http/modules/ngx_http_auth_basic_module.c

NGINX 配置测试

# info.nginx
location = "/info.nginx" {

    auth_basic           "Administrator's Area";
    auth_basic_user_file /etc/nginx/.htpasswd;

    access_log    off;
    default_type  "application/json; charset=UTF-8";
    return        200 '{"nginx_version":"$nginx_version","time":{"time_iso8601":"$time_iso8601","time_local":"$time_local","msec":"$msec"},"remote":{"remote_addr":"$remote_addr","remote_port":"$remote_port"},"host":{"host":"$host","hostname":"$hostname"},"server":{"server_addr":"$server_addr","server_name":"$server_name","server_port":"$server_port","server_protocol":"$server_protocol"},"request":{"request_time":"$request_time","request_method":"$request_method","request_uri":"$request_uri","request_filename":"$request_filename","uri":"$uri","query_string":"$query_string","realpath_root":"$realpath_root"},"document":{"document_root":"$document_root","document_uri":"$document_uri"}}';
}
nginx
  • 2 个回答
  • 151 Views
Martin Hope
suchislife
Asked: 2021-08-29 05:42:55 +0800 CST

忽略任何和所有 url 参数以加强安全性。如何?

  • 1

access.log任何将 NGINX 服务器上线并在一周后查看它的人都会发现许多 URL 漏洞正在尝试。每天,任何时间。

那么,如果我拒绝任何和所有 url 参数呢?如果每个查询字符串都被 NGINX 屏蔽,而 NGINXrewrite将无法匹配任何未定义为rewrite自然返回 404 Not Found 的内容怎么办?

或者一系列重写以放置在这个始终存在的位置块内?

location / {
  rewrite "^/api/v1/users/?$" /api/v1/Users.php last;
  rewrite "^/api/v1/users/(all|active|inactive)?$" /api/v1/Users.php?status=$1 last;
  rewrite "^/api/v1/users/(\d+)/?$" /api/v1/Users.php?userId=$1 last;
}

# URL Match examples...

http://localhost/api/v1/users
http://localhost/api/v1/users/

http://localhost/api/v1/users/all
http://localhost/api/v1/users/active
http://localhost/api/v1/users/inactive

http://localhost/api/v1/users/2001
http://localhost/api/v1/users/2002
http://localhost/api/v1/users/2003

有没有办法让 NGINX 忽略 URL 参数?如果这是一个幼稚的问题,请随时告诉我。也许我问错了问题。

nginx
  • 1 个回答
  • 80 Views
Martin Hope
suchislife
Asked: 2020-12-02 14:15:26 +0800 CST

Windows 10 Pro 作为带有 SSL 证书的 RDP 主机。如何?

  • 2

我已经用尽了耐心寻找如何将 SSL 证书添加到我的 Windows 10 Pro 机器,以便当我从另一个地方连接时,我不会收到证书错误。

到目前为止,我遇到的每一个指南最终都被证明是针对 Windows Server 的。

我试过的:

我单击开始菜单,然后键入certlm.msc并按 Enter。

我将购买的证书放在主机的Personal > Certificates文件夹和Remote Desktop > Certificate Service文件夹中。

在此处输入图像描述

当我尝试从另一台机器重新连接时,我仍然收到证书信任错误。

任何人都可以帮忙吗?

同样,我试图在 Windows 10 Pro 机器上完成此操作,而不是 Windows Server。

remote-desktop security ssl-certificate windows-10
  • 1 个回答
  • 2206 Views
Martin Hope
suchislife
Asked: 2020-04-06 10:13:09 +0800 CST

limit_except VS $request_method !~ ^(GET|HEAD|POST)$

  • 2

我最近读了很多关于nginx的文章,并在网上找到了两种方法。第一个似乎在服务器上下文级别工作,第二个建议用于位置上下文级别。

问题。limit_except在服务器上下文级别使用是否合适?

方法 #1 ($request_method) 嵌入变量

# server context
#
# Disable unwanted HTTP methods
# Most of the time, you need just GET, HEAD & POST HTTP request in your web application.
# Allowing TRACE or DELETE is risky as it can allow Cross-Site Tracking attack and potentially
# allow an attacker to steal the cookie information.
# So we return a 405 Not Allowed if someone is trying to use TRACE, DELETE, PUT, OPTIONS.

if ($request_method !~ ^(GET|HEAD|POST)$ ) {

  return 405;

}

方法 #2 ( limit_except ) 方法

# Limits allowed HTTP methods inside a location.
. . .

location /restricted-write {

    # location context

    limit_except GET HEAD {

        # limit_except context

        allow 192.168.1.1/24;
        deny all;
    }
}
nginx php-fpm
  • 2 个回答
  • 1802 Views
Martin Hope
suchislife
Asked: 2020-03-29 10:03:29 +0800 CST

NGINX 干净的 URL 重写。如何?

  • 0

我花了几个小时试图在 NGINX 中弄清楚Apache 中的其他和难以置信的微不足道的任务。

我累死...

我已经安装了 NGINX 开箱即用。

html是根文件夹。

我

JSON 内部接口

html
html/api
html/api/v1
html/api/v1/getUsers.php

HTML 外部接口

html
html/gui
html/gui/v1
html/gui/v1/get/users/1001

我有一个工作位置块,它说明了最终目标。

location = /get/users/1001 {

  add_header Content-Type text/plain;
  return 200 'This non physical URL path needs to point to html/api/v1/getUsers.php?userId=1001';

}

一个人怎么可能做到这一点。我真的要回到 Apache 并且永不回头。

这是我如何通过将以下 Apache 指令放置在位于html/gui/v1

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^get/users/(\d+)/?$ getUser.php?userId=$1 [L]
nginx regex
  • 1 个回答
  • 115 Views
Martin Hope
suchislife
Asked: 2020-03-22 19:22:38 +0800 CST

对于没有索引文件,共享主机返回 403。本地主机返回 404。如何?

  • 1

当用户导航到不包含index.php的文件夹时,我的共享托管服务返回 apache 403 错误

当用户导航到不包含index.php的同一文件夹时,我的本地主机返回 apache 404 错误

我的 localhost apache 服务器当前禁用了以下模块:

#LoadModule autoindex_module modules/mod_autoindex.so

现在我不认为这是一个问题,因为服务器确实没有找到文件,因此它确实应该返回 404。

我很好奇我的共享托管 apache 服务器如何选择返回 403 错误。

.htaccess apache-2.4
  • 1 个回答
  • 47 Views
Martin Hope
suchislife
Asked: 2020-03-01 23:59:53 +0800 CST

RewriteRule 在 root 中不起作用。仅在当前文件夹中

  • 1

我已经阅读了几个小时的文章,但是由于没有控制台输出来调试 htaccess 文件,我完全感到沮丧。

丑陋的文件夹结构:

/html/api/v2/estimates/index.php?status=completed
/html/api/v2/estimate/index.php?id=1001
/html/api/v2/proposals/index.php?status=accepted
/html/api/v2/proposal/index.php?id=1001
/html/api/v2/contracts/index.php?status=signed
/html/api/v2/contract/index.php?id=1001
/html/api/v2/invoices/index.php?status=sent
/html/api/v2/invoice/index.php?id=1001

所需的文件夹结构:

/html/api/v2/estimates/completed
/html/api/v2/estimate/1001
/html/api/v2/proposals/accepted
/html/api/v2/proposal/1001
/html/api/v2/contracts/signed
/html/api/v2/contract/1001
/html/api/v2/invoices/sent
/html/api/v2/invoice/1001

我的数字 .htaccess 仅在我将它们放在目录估计、提案、合同和发票中时才有效。

例子:

<IfModule mod_rewrite.c>

  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f

  RewriteRule ^(\d+)/?$ index.php?id=$1

</IfModule>

我的字符串 .htaccess 仅在我将它们放在目录估计、建议、合同和发票中时才有效。

例子:

<IfModule mod_rewrite.c>

  Options +FollowSymLinks
  RewriteEngine On

  RewriteCond %{SCRIPT_FILENAME} !-d
  RewriteCond %{SCRIPT_FILENAME} !-f

  RewriteRule ^(\w+)/?$ index.php?status=$1

</IfModule>

如果我要将htaccess 文件放在/v2文件夹中,我需要在上面的这些脚本中修改什么?

.htaccess apache-2.4
  • 1 个回答
  • 106 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