Goal: I'm trying to setup varnish on my Ubuntu webserver. I've read the docs and getting started stuff, doesn't look too complicated, however, I don't think my site is ever being cached by it.
I am running a nodeJS server (using express). The app listens to port 3000, and my Ubuntu server is forwarding requests from port 80 to port 3000 using:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
In my /etc/default/varnish config I have this block uncommented and edited:
## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request. Use a 1GB
# fixed-size cache file.
#
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
I'm honestly not sure what this should be set to, other than the docs say to change -a :6082 to -a :80. The localhost part is confusing me, i'm not sure if it trying to refer to apache or the local system?
Also, when somebody hits my site, are they still hitting port 80 at all and THEN getting forwarded to port 3000, or do they automatically hit port 3000 because of my iptables rule. Is there a definitive way to tell if varnish is setup correctly? Does it send a header or anything?
My profession is web development and the only linux stuff i know is self taught to work with servers. I'm keen to learn, so please let me know if you need more information from me.