0

我在 Centos 上安装了 Varnish 4.0.1 和 Apache 2.4.6。问题是为什么我无法访问该网站。看看netstat下面

在此处输入图像描述

还有什么要检查以使其像往常一样运行。这是更多的配置httpd.conf

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 127.0.0.1:8080
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName example.my:8080

我按照这个网站的一步一步修改,SELinux但我已经撤消到以前的值,即disabled

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

教程还让我修改了iptables,和上面一样,我把它恢复到原来的样子

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

这是我的default.vcl

# Default backend definition. Set this to point to your content server.
backend default {
    .host = "127.0.0.1";
    .port = "8080";
    .max_connections = 15;
    .connect_timeout = 4.0s;
    .first_byte_timeout = 600s;
    .between_bytes_timeout = 600s;
}

varnish.params

# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings

# Set this to 1 to make systemd reload try to switch vcl without restart.
RELOAD_VCL=1

# Main configuration file. You probably want to change it.
VARNISH_VCL_CONF=/etc/varnish/default.vcl

# Default address and port to bind to. Blank address means all IPv4
# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted
# quad, or an IPv6 address in brackets.
#VARNISH_LISTEN_ADDRESS=127.0.0.1
VARNISH_LISTEN_PORT=80

# Admin interface listen address and port
VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1
VARNISH_ADMIN_LISTEN_PORT=6082

# Shared secret file for admin interface
VARNISH_SECRET_FILE=/etc/varnish/secret

# Backend storage specification, see Storage Types in the varnishd(5)
# man page for details.
#VARNISH_STORAGE="file,/var/lib/varnish/varnish_storage.bin,1G"
VARNISH_STORAGE="malloc,256m"

# Default TTL used when the backend does not specify one
VARNISH_TTL=120

# User and group for the varnishd worker processes
VARNISH_USER=varnish
VARNISH_GROUP=varnish

# Other options, see the man page varnishd(1)
#DAEMON_OPTS="-a :80 -p thread_pool_min=5 -p thread_pool_max=500 -p thread_pool_timeout=300"

access_log在 httpd 文件夹中

127.0.0.1 - - [19/Dec/2014:10:10:29 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:10:10:29 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:10:10:29 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:08:39 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:08:39 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:08:39 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:08:39 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:08:39 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:24:16 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:24:16 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"
127.0.0.1 - - [19/Dec/2014:11:24:16 +0800] "OPTIONS * HTTP/1.0" 200 - "-" "Apache/2.4.6 (CentOS) (internal dummy connection)"

在这里我发现了什么error_log

[Fri Dec 19 11:50:38.318727 2014] [mpm_prefork:notice] [pid 8182] AH00170: caught SIGWINCH, shutting down gracefully
[Fri Dec 19 11:50:39.495826 2014] [suexec:notice] [pid 8610] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Dec 19 11:50:39.587231 2014] [mpm_prefork:notice] [pid 8610] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Fri Dec 19 11:50:39.587286 2014] [core:notice] [pid 8610] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

这里varnishstat

Uptime mgt:   0+00:25:46
Uptime child: 0+00:25:46

  NAME                                                                                            CURRENT       CHANGE      AVERAGE       AVG_10      AVG_100     AVG_1000
MAIN.uptime                                                                                          1546         1.00         1.00         1.00         1.00         1.00
MAIN.pools                                                                                              2         0.00          .           2.00         2.00         2.00
MAIN.threads                                                                                          200         0.00          .         200.00       200.00       200.00
MAIN.threads_created                                                                                  200         0.00          .           0.00         0.00         0.00
MAIN.n_backend                                                                                          1         0.00          .           1.00         1.00         1.00
MAIN.n_vcl                                                                                              1         0.00          .           0.00         0.00         0.00
MAIN.bans                                                                                               1         0.00          .           1.00         1.00         1.00
MGT.uptime                                                                                           1546         1.00         1.00         1.00         1.00         1.00
SMA.s0.g_space                                                                                  268435456         0.00          .   268435456.00 268435456.00 268435456.00

我还有什么要检查的。感谢您对此的帮助。谢谢

4

1 回答 1

1

您需要允许从 Internet 到端口 80 的流量。编辑 iptables 配置如下:

# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

也就是说, -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 在该行下方 添加-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

然后重新启动 iptables 或重新加载配置。

于 2014-12-19T10:50:37.880 回答