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

Abs's questions

Martin Hope
Abs
Asked: 2017-08-30 05:15:43 +0800 CST

如何让 Apache 访问 ubuntu 上的 ip-tables

  • 0

我在一个新Ubuntu 14.04.5 x64盒子上运行了下面的脚本。它的工作原理是 apache 按预期阻止我的 IP 地址以处理太多请求。但是,我的 IP 地址没有添加到iptables. 我只是得到一个标准的 403,但我希望数据包被丢弃而没有错误。

我认为问题在于apache无法运行的权限ip-tables。但我无法弄清楚,因为我已经让apache用户www-data能够iptables在sudoers文件中运行。

任何帮助表示赞赏,我整天都在为此烦恼!

#!/bin/sh

apt-get update
apt-get -y install apache2

# Install mod evasive
apt-get -y install libapache2-mod-evasive

# Enable it
a2enmod evasive
a2enconf evasive

# Create log directory
mkdir /var/log/mod_evasive
chown -R www-data:www-data /var/log/mod_evasive

# Config for mod evasive
cat <<'EOF' > /etc/apache2/mods-available/evasive.conf
  <IfModule mod_evasive20.c>
      DOSHashTableSize     3097

      # Allow 5 requests for the same resource request per second. Per-IP
      DOSPageCount          5
      DOSPageInterval       1

      # Allow up to 50 requests across the domain per second. Per-IP
      DOSSiteCount          50
      DOSSiteInterval       1

      # Block user by IP for 60 minutes
      DOSBlockingPeriod     60

      DOSSystemCommand      "sudo /usr/local/bin/ban_ip.sh %s"

      DOSLogDir             /var/log/mod_evasive
      DOSWhitelist          188.88.90.71
      DOSWhitelist          188.88.90.72
      DOSWhitelist          188.88.90.73
  </IfModule>
EOF

# Config for banning users
cat <<'EOF' > /usr/local/bin/ban_ip.sh
#!/bin/sh

# Offending IP as detected by mod_evasive
IP=$1

# Path to iptables binary executed by user www-data through sudo
IPTABLES="/sbin/iptables"

# mod_evasive lock directory
MOD_EVASIVE_LOGDIR=/var/log/mod_evasive

# Add the following firewall rule (block IP)
sudo $IPTABLES -I INPUT -s $IP -j DROP

# Unblock offending IP after 2 hours through the 'at' command; see 'man at' for further details
echo "sudo $IPTABLES -D INPUT -s $IP -j DROP" | sudo at now + 1 minute

# Remove lock file for future checks
sudo rm -f "$MOD_EVASIVE_LOGDIR"/dos-"$IP"
EOF

echo 'www-data ALL=NOPASSWD: /sbin/iptables *, /usr/bin/at *' | EDITOR='tee -a' visudo
iptables
  • 1 个回答
  • 516 Views
Martin Hope
Abs
Asked: 2015-03-24 04:14:58 +0800 CST

强制 HTTPS 时的重定向循环

  • 1

我正在使用以下内容在我的主网站上强制使用 HTTPS。

### Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

如果你想查看完整的 htaccess 文件,我把它放在下面:

<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    ### Blacklist via Referrers

    RewriteCond %{HTTP_REFERER} removed\.net [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.net [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.sx [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} removed\.org [NC]
    RewriteRule ^(.*)$ - [F,L]

    ### Force SSL
    #RewriteCond %{HTTPS} !=on
    #RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    ### Canonicalize codeigniter URLs

    # If your default controller is something other than
    # "welcome" you should probably change this
    RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    # Enforce NO www
    RewriteCond %{HTTP_HOST} ^www [NC]
    RewriteRule ^(.*)$ https://removed.com/$1 [L,R=301]

    # Removes access to the system folder by users.
    # Additionally this will allow you to create a System.php controller,
    # previously this would not have been possible.
    # 'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

<IfModule !mod_rewrite.c>

    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php

</IfModule>

我正在努力弄清楚重定向循环是如何发生的。

更新

我没有明确说明我的 Web 服务器 (Apache) 仅在端口 80 上配置了一个虚拟主机,该主机将 HTTP 和 HTTPS 流量通过负载平衡器定向到它。负载平衡器处理 SSL 连接。

ssl
  • 2 个回答
  • 21248 Views
Martin Hope
Abs
Asked: 2013-12-27 07:27:07 +0800 CST

在没有重定向的情况下将目录重写到另一个目录[重复]

  • 1
这个问题在这里已经有了答案:
在 Apache 中重定向、更改 URL 或将 HTTP 重定向到 HTTPS - 您想知道的关于 mod_rewrite 规则但不敢问的一切 (5 个答案)
8年前关闭。

我有以下重写规则:

RewriteRule ^support/(.*)$ /blog/support/$1 [R=301,NC,L]

但是,它所做的只是一个简单的重定向。我想要的是在不更改 URL/support的情况下显示. 我怎样才能做到这一点?/blog/support/support

此外,上述内容仅在/support有斜杠时才有效。

apache-2.2
  • 1 个回答
  • 8310 Views
Martin Hope
Abs
Asked: 2013-05-30 12:34:27 +0800 CST

nginx - 客户端请求正文被缓冲到一个临时文件

  • 99

每次尝试上传大文件时,我的日志文件中都会出现以下错误。

a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001

虽然文件上传成功,但我总是得到上面的错误。

我增加了client_body_buffer_size我1000m期望上传的最大文件的大小。然而,这只是一个猜测,虽然我没有再收到那个错误,但我想知道这是否是为client_body_buffer_size?设置的合适值。

如果有人能阐明这个指令以及应该如何使用它,我将不胜感激。

nginx
  • 2 个回答
  • 183497 Views
Martin Hope
Abs
Asked: 2012-12-13 02:24:44 +0800 CST

使用varnishtop时浮点数表示什么?

  • 1

我正在运行 Varnish,我想看看通常会出现哪些 http 响应代码。我用了:

varnishtop -i TxStatus

但是,我正在努力弄清楚左边的数字是什么意思?是请求数吗?

list length 7

  1322.16 TxStatus       200
    60.43 TxStatus       302
     8.67 TxStatus       304
     3.14 TxStatus       500
     2.96 TxStatus       404
     0.80 TxStatus       301
     0.56 TxStatus       403
varnish
  • 1 个回答
  • 250 Views
Martin Hope
Abs
Asked: 2012-11-14 02:17:55 +0800 CST

清除 cmd.exe 内存或缓存

  • 0

主要问题是如何清除命令提示内存或缓存。

我在 cmd.exe 上运行了这个

svn info <URL>

这提示我输入我输入的用户名和密码。

然后我注销并立即重新登录并输入相同的命令并且没有要求我输入用户名和密码。我想清除它以在不重新启动服务器的情况下测试一些东西!

我怎样才能做到这一点?

windows
  • 1 个回答
  • 1205 Views
Martin Hope
Abs
Asked: 2012-10-26 01:11:11 +0800 CST

使用 Varnish 循环法的负载均衡器

  • 1

我正在查看现有应用程序的设置。此应用程序使用亚马逊的弹性负载均衡器,然后通过清漆。在清漆中,我们正在使用循环负载均衡器……这是多余的吗?

我的设置示例

在此处输入图像描述

我们正在使用directoras round-robin。

load-balancing
  • 1 个回答
  • 1229 Views
Martin Hope
Abs
Asked: 2012-09-10 09:44:04 +0800 CST

htaccess 重定向向 url 添加问号

  • 0

我的 htaccess 中有以下内容:

#When your application folder isn't in the system folder
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?/$1 [L]

#No WWW
RewriteCond %{HTTP_HOST} !^myrealdomain.com$ [NC]
RewriteRule ^(.*)$ https://myrealdomain.com/$1 [L,R=301]

#Always redirect to SSL pages
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

我希望www被重定向,我希望所有页面都是https。它似乎有效,但是当我尝试转到https://www.d.com/hello它时,它会重定向到https://d.com/?/hello.

那个多余的问号是从哪里来的?

此外,创建一个类似 facebook 的按钮似乎根本不喜欢我的域。该按钮显示为空白,我认为它与上述内容有关...?

非常感谢任何帮助。

.htaccess
  • 1 个回答
  • 2303 Views
Martin Hope
Abs
Asked: 2009-08-28 02:21:59 +0800 CST

NameServers Changed:如何检查访问我服务器的域名?

  • 0

如何检查已用于使用 PHP 访问我的服务器的域名?

我有几个域,我已经更改了名称服务器,现在我希望能够检查正在访问我的服务器的域?

将不胜感激链接阅读这类事情和如何测试。

谢谢大家

php apache-2.2 ip domain nameserver
  • 3 个回答
  • 500 Views
Martin Hope
Abs
Asked: 2009-05-23 14:42:32 +0800 CST

如何减少服务器上的 RAM 使用量?

  • 4

我最近推出了一个非常受欢迎的网站,但我在可扩展性方面遇到了问题。我的网站大量使用FFmpeg,在高峰时间 RAM 使用量迅速达到 2 GB 点,并且交换文件开始被使用。CPU 使用率也开始上升。

用户抱怨网站运行缓慢。他们这样说是因为所有 FFmpeg 实例由于同时运行的数量而运行速度非常慢。用户在我的服务器上实时使用 FFmpeg。

我有什么可以考虑或做的事情来减轻服务器和 RAM 的使用量吗?也许有比 FFmpeg (!) 更好的东西。

唯一的解决方案是在更强大的服务器上“扔一些钱”吗?

我提供的信息很少,请多问,这样可以解决这个问题。

linux scalability ffmpeg
  • 6 个回答
  • 6760 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