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-197517

bdesham's questions

Martin Hope
bdesham
Asked: 2015-08-19 08:19:00 +0800 CST

nginx的“主线”和“稳定”分支有什么区别?

  • 78

nginx web 服务器似乎有两个活动分支:一个“主线”分支(当前为 1.9.x)和一个“稳定”分支(当前为 1.8.x)。任何人都可以提供一个官方资料来描述这两个分支之间的区别以及如何在它们之间进行选择?

nginx
  • 1 个回答
  • 40711 Views
Martin Hope
bdesham
Asked: 2015-01-24 12:27:07 +0800 CST

如何阻止设置了错误 Host 标头的请求?

  • 15

我使用 nginx 来服务我的网站。我想阻止所有带有与我的站点域不匹配的 HTTP“主机”标头的请求。

更具体地说,我的 nginx.conf 包含这两个服务器块:

server {
    # Redirect from the old domain to the new domain; also redirect
    # from www.newdomain.com to newdomain.com without the "www"
    server_name www.olddomain.com olddomain.com www.newdomain.com;
    listen 80;
    return 301 $scheme://newdomain.com$request_uri;
}

server {
    server_name newdomain.com localhost;
    listen 80;

    # Actual configuration goes here...
}

我想阻止(即“返回”444 状态代码)主机不是 www.olddomain.com、olddomain.com、www.newdomain.com 或 newdomain.com 的任何流量。我怎样才能做到这一点?

nginx
  • 2 个回答
  • 11123 Views
Martin Hope
bdesham
Asked: 2014-11-23 09:46:33 +0800 CST

有没有一种优雅的方法可以一次阻止一堆推荐人?

  • 23

为了防止引用垃圾邮件,我的 nginx.conf 包含这样的部分:

if ($http_referer ~* spamdomain1\.com) {
    return 444;
}
if ($http_referer ~* spamdomain2\.com) {
    return 444;
}
if ($http_referer ~* spamdomain3\.com) {
    return 444;
}

如果用户设置了这些引用者之一,这些规则告诉 nginx 关闭连接。有没有更优雅的方法来做到这一点?我可以定义这些域的列表,然后说“如果引用者在此列表中,则返回 444”?

nginx
  • 3 个回答
  • 18013 Views
Martin Hope
bdesham
Asked: 2014-05-30 08:57:21 +0800 CST

在我的系统上对磁盘进行原子写入的大小是多少?

  • 13

在指令的文档中access_log,nginx 文档说

缓冲区大小不得超过对磁盘文件的原子写入大小。

如何确定我的系统上的这个大小?

linux
  • 2 个回答
  • 3775 Views
Martin Hope
bdesham
Asked: 2014-05-21 10:46:33 +0800 CST

使用 nginx 从 URL 中删除尾部斜杠

  • 17

我希望我网站上的以下 URL 是等效的:

/foo/bar
/foo/bar/
/foo/bar/index.html

此外,我希望后两种形式将 HTTP 301 重定向到第一种形式。我只是提供静态页面,它们是按照第三种形式排列的。(换句话说,当用户请求时,/foo/bar他们应该在 接收文件/usr/share/.../foo/bar/index.html)。

我nginx.conf目前包含以下内容:

rewrite ^(.+)/$ $1 permanent;
index index.html;
try_files $uri $uri/index.html =404;

这对. /foo/bar/index.html_ 如何让 nginx 以我描述的方式将 URL 映射到文件?/foo/bar/foo/bar/

编辑:我的完整配置

这是我的全部内容nginx.conf,我的域名替换为“example.com”。

user www-data;
worker_processes 1;
pid /run/nginx.pid;

events {
  worker_connections 768;
}

http {
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  server_tokens off;

  server_names_hash_bucket_size 64;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss application/atom+xml text/javascript image/svg+xml;

  server {
    server_name www.example.com;
    listen 80;
    return 301 $scheme://example.com$request_uri;
  }

  server {
    server_name example.com 123.45.67.89 localhost;
    listen 80 default_server;

    # Redirect /foobar/ to /foobar
    rewrite ^(.+)/$ $1 permanent;

    root /usr/share/nginx/www/example.com;
    index index.html;
    try_files $uri $uri/index.html =404;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location = /50x.html {
      root /usr/share/nginx/html;
    }
  }
}
nginx
  • 5 个回答
  • 59554 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