diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2016-02-20 21:24:23 +0100 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2016-02-20 21:24:23 +0100 |
commit | 938a2c4661fc965f84bb9e54e6ed24c873d36fd0 (patch) | |
tree | 1f647d8d89fc3644a839842c2f0b0f81883d1d46 | |
parent | cf5d2c93b851e253d5e0cf5a969bb96f8fea4e93 (diff) |
nms: Work on default setup
-rw-r--r-- | nms/Dockerfile.in | 14 | ||||
-rw-r--r-- | web/etc/varnish/nms.vcl | 74 |
2 files changed, 87 insertions, 1 deletions
diff --git a/nms/Dockerfile.in b/nms/Dockerfile.in index 3782325..c3d861a 100644 --- a/nms/Dockerfile.in +++ b/nms/Dockerfile.in @@ -4,7 +4,7 @@ FROM debian:jessie ENV container docker MAINTAINER "Kristian" <kly@kly.no> -RUN systemctl set-default basic.target +#RUN systemctl set-default basic.target RUN apt-get update && apt-get -y install \ wget \ vim \ @@ -44,6 +44,7 @@ ADD .vimrc /root/.vimrc RUN rm /etc/apt/apt.conf.d/docker-clean RUN systemctl mask dev-hugepages.mount sys-fs-fuse-connections.mount RUN git clone https://github.com/tech-server/tgmanage.git root/tgmanage +RUN systemctl disable systemd-logind.service CMD ["/sbin/init"] @@ -52,7 +53,18 @@ FROM nms-base RUN apt-get -y install libcapture-tiny-perl libcgi-pm-perl libcommon-sense-perl libdata-dumper-simple-perl libdbi-perl libdigest-perl libgd-perl libgeo-ip-perl libhtml-parser-perl libhtml-template-perl libimage-magick-perl libimage-magick-q16-perl libjson-perl libjson-xs-perl libnetaddr-ip-perl libnet-cidr-perl libnet-ip-perl libnet-openssh-perl libnet-oping-perl libnet-rawip-perl libnet-telnet-cisco-perl libnet-telnet-perl libsnmp-perl libsocket6-perl libsocket-perl libswitch-perl libtimedate-perl perl perl-base perl-modules RUN cd /root/tgmanage/ && tools/get_mibs.sh +RUN apt-get -y install apache2 +RUN sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/ports.conf +RUN a2dissite 000-default +RUN cd /root/tgmanage/ && git pull +RUN ln -s /root/tgmanage/web/etc/apache2/nms.tg16.gathering.org.conf /etc/apache2/sites-enabled/ +RUN ln -s /root/tgmanage/web/etc/varnish/nms.vcl +RUN systemctl enable apache2 +RUN apt-get -y install varnish +RUN systemctl enable varnish + @template nms-db FROM nms-base RUN apt-get install -y postgresql-doc-9.4 postgresql-9.4 + diff --git a/web/etc/varnish/nms.vcl b/web/etc/varnish/nms.vcl new file mode 100644 index 0000000..5f262a6 --- /dev/null +++ b/web/etc/varnish/nms.vcl @@ -0,0 +1,74 @@ +# +# This is an example VCL file for Varnish. +# +# It does not do anything by default, delegating control to the +# builtin VCL. The builtin VCL is called when there is no explicit +# return statement. +# +# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ +# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. + +# Marker to tell the VCL compiler that this VCL has been adapted to the +# new 4.0 format. +vcl 4.0; + +# Default backend definition. Set this to point to your content server. +backend default { + .host = "127.0.0.1"; + .port = "8080"; +} + +sub vcl_recv { + + if (req.method != "GET" && + req.method != "HEAD" && + req.method != "PUT" && + req.method != "POST" && + req.method != "TRACE" && + req.method != "OPTIONS" && + req.method != "DELETE") { + /* Non-RFC2616 or CONNECT which is weird. */ + return (pipe); + } + + # Hardcoded for testing + set req.http.host = "nms.tg16.gathering.org"; + + if (req.method != "GET" && req.method != "HEAD") { + /* We only deal with GET and HEAD by default */ + return (pass); + } + + unset req.http.Cookie; + + return (hash); + } + +sub vcl_hash { + hash_data(req.http.authorization); +} + +sub vcl_backend_response { + # Happens after we have read the response headers from the backend. + # + # Here you clean the response headers, removing silly Set-Cookie headers + # and other mistakes your backend does. + if (!(bereq.http.host ~ "stream")) { + if (beresp.status == 200) { + set beresp.ttl = 2s; + } else { + set beresp.ttl = 0s; + } + if(bereq.url ~ "port-state.pl" && beresp.status == 200) { + set beresp.ttl = 1s; + } + if (beresp.status == 200 && bereq.url ~ "now=") { + set beresp.ttl = 60m; + } + if (beresp.status == 500) { + return (retry); + } + } + +} + |