0

I'm stuck at some point in the installation of Varnish. This is how it looked like before the Varnish: Nginx Reverse Proxy + Apache + Centos 6 64 Bit

I installed the Varnish and set the ports as following. First of all we want to remove Nginx Reverse Proxy and switch to Apache completely. Because Varnish is not working properly at the moment.

DEFAULT.VCL

backend default {

.host = "127.0.0.1";

.port = "8080";

.first_byte_timeout = 60s;

.connect_timeout = 300s;
}

VARNISH

DAEMON_OPTS="-a :80 \

-T localhost:6082 \

-f /etc/varnish/default.vcl \

-u varnish -g varnish \

-S /etc/varnish/secret \

-s file,/var/lib/varnish/varnish_storage.bin,256m"

httpd.conf

#
# 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 8080

nginx-vhosts.conf

  server {
        listen       176.xx.xx.xx:80;
        listen       127.0.0.1:80;
        #listen       [::1]:80;
        server_name  $hostname 176.xx.xx.xx;

        root   /var/www/html;
        index  index.html index.htm index.php;

        include /etc/nginx/nginx-userdir.conf;

        location / {
                access_log off;
                proxy_pass http://176.xx.xx.xx:8080;
                proxy_set_header X-Client-IP      $remote_addr;
                proxy_set_header X-Accel-Internal /nginx_static_files;
                proxy_set_header Host             $host;
                proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

I used the curl -l command for localhost and domain.com. How should i set the ports and IPs in order to make Varnish work properly?

Localhost

[root@ns1 ~]# curl -I http://localhost
HTTP/1.1 200 OK
Date: Thu, 14 Jul 2016 11:35:43 GMT
Server: Apache/2
X-Powered-By: W3 Total Cache/0.9.4.1
Link: <http://******.com/wp-json/>; rel="https://api.w.org/"
Cache-Control: max-age=3600
Expires: Thu, 14 Jul 2016 12:35:43 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding
X-Varnish: 2
Age: 0
Via: 1.1 varnish-v4
X-Cache: MISS
Connection: keep-alive

my domain.com

[root@ns1 ~]# curl -I http://my domain.com
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 14 Jul 2016 11:36:07 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 344285
Connection: close
Vary: Accept-Encoding
Last-Modified: Thu, 14 Jul 2016 11:30:57 GMT
ETag: "540dd-53796d5f31b86"
Accept-Ranges: bytes
Vary: Accept-Encoding,User-Agent
Cache-Control: public, must-revalidate, proxy-revalidate
Expires: Thu, 14 Jul 2016 12:30:57 GMT
X-Powered-By: W3 Total Cache/0.9.4.1
Pragma: public
4
  • Please edit your question and provide information on how you expect traffic to flow through the various server processes. Also, in this case is Apache even in use? If not, remove it from the question, as it's just noise.
    – EEAA
    Jul 14, 2016 at 12:47
  • Actually we want to remove Nginx completely then use Apache + Varnish instead of it. I guess Nginx Reverse Proxy makes the problem right?,-
    – Ayberk
    Jul 14, 2016 at 13:27
  • As I mentioned, please edit your question to clarify what you are trying to do.
    – EEAA
    Jul 14, 2016 at 13:48
  • I added what we wanted to do exactly.
    – Ayberk
    Jul 14, 2016 at 14:11

1 Answer 1

0

What's the problem? All seems correct. Remove Nginx. Then restart Apache and then restart Varnish.

11
  • Varnish seems in a passive state. imgur.com/OlnV2UO I guess Nginx creates a problem here.
    – Ayberk
    Jul 14, 2016 at 18:17
  • It is obvious from your curl results that you have Varnish and Nginx listening on same port 80 but different interfaces. You said yourself you don't need Nginx. So do yourself a favor and remove it then restart the services to make sure Varnish listens on external interface :) Jul 14, 2016 at 18:27
  • HTTPD error: imgur.com/yk0hyzb :/ What's the problem?
    – Ayberk
    Jul 14, 2016 at 22:03
  • Make sure you removed Nginx: sudo apt-get remove nginx (Ubuntu) or yum remove nginx (CentOS / Redhat) . Remove any Listen 1.2.3.4:80 or Listen 80 directive in Apache. Restart Apache and Varnish. Jul 14, 2016 at 22:37
  • Yes, Nginx has been removed. Now; backend default { .host = "MY SERVER IP"; .port = "8080"; .first_byte_timeout = 60s; .connect_timeout = 300s; VARNISH_LISTEN_PORT=80 Httpd.conf: Listen 8080 is it correct?
    – Ayberk
    Jul 14, 2016 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .