Varnish 5 deafult.vcl issue - varnish-vcl

Varnish 5 failing to start if I use use vcl 5.1; or vcl 5.0; in my default.vcl
Varnish5 docs says:
Starting with Varnish 4.0, each VCL file must start by declaring its version with "vcl X.Y;" marker at the top of the file.
but I'm using Varnish 5.1
I tried vcl 5.0; or vcl 5.1; in my default.vcl but it didn't work.

This is explained in the man page vcl(7) under VERSIONING (from a Varnish 5.0.0 installation on Debian 9):
Multiple versions of the VCL syntax can coexist within certain
constraints.
The VCL syntax version at the start of VCL file specified with
''-f'' sets the hard limit that cannot be exceeded anywhere, and
it selects the appropriate version of the builtin VCL.
That means that you can never include "vcl 9.1;" from "vcl
8.7;", but the opposite may be possible, to the extent the com‐
piler supports it.
Files pulled in via include do not need to have a "vcl X.Y;" but
it may be a good idea to do it anyway, to not have surprises in
the future. The syntax version set in an included file only
applies to that file and any files it includes - unless these
set their own VCL syntax version.
The version of Varnish this file belongs to supports **syntax 4.0**
only.

Related

How to completely remove Xserver from OpenBSD?

I just installed OpenBSD 6.9 to study how it works.
I wanted to get the most minimal config possible, because I want to use it as a server.
During instalation I chose the option to not install Xserver, but I still have the /usr/X11R6 and /etc/X11 directories with X config and commands like startx. The only difference is that now, startx doesn't work. I tried installing on VirtualBox and on bare metal and both were the same.
What do I have to do in order to completely remove X from OpenBSD? And why is it still being installed in my machine even if I explicitly write "no" when prompted during installation?
My system:
OpenBSD 6.9
Intel Pentium G5400
Nvidia 1050 ti.
OpenBSD installation uses different file sets => see OpenBSD FAQ / File Sets
X11 installation is split into 4 file sets :
xbase71.tgz : Base libraries and utilities for X11 (requires xshare71.tgz)
xfont71.tgz : Fonts used by X11
xserv71.tgz : X11's X servers
xshare71.tgz : X11's man pages, locale settings and includes
During installation, you chose not to install xserv71.tgz (X servers) but you still have installed xbase71.tgz (startx command and others directories).
If you want to completely remove X from OpenBSD, during installation, remove every file set for X. But you should keep xbase71.tgz because some programs needs it to run correctly even if it's a non-X program.
I'm not a OpenBSD developer, so I cannot give a clear answer. But some specific packages which you can add with the package command from OpenBSD (pkg_add), needs some X libraries or binaries.
As example when you want to add vim for the first time, then you have eight flavors:
$ pkg_info -d vim-8.2.3456-no_x11
Information for inst:vim-8.2.3456-no_x11
[REMOVED]
Flavors:
gtk2 - build using the Gtk+2 toolkit
gtk3 - build using the Gtk+3 toolkit (default)
no_x11 - build without X11 support
lua - build with Lua support
perl - build with Perl support
python - build with Python support
python3 - build with Python3 support
ruby - build with Ruby support
It's depends on the packages what you need. Also when you want install something from the port collections.
You can try the quick and dirty way and simple remove your mentioned directories. But I could be possible that some programs from the base system no longer works, because of missing dependencies.

Using luac file on Nginx

I have been experimenting with using Lua in Nginx - quite a neat little capability which I can use effectively. However, one of my concerns relates to IP protection so I thought I would use an online tool to compile my, fully tested, LUA script. I tried https://luac.mtasa.com/.
I uploaded the file to my server, changed by /etc/nginx/sites-available/default file to use the luac* instead of the orginal lua and reloaded nginx. However, when I attempt to browse to the resource that is being serviced by that lua(c) I get the error log message *70 failed to load external Lua file... : bad byte code header. How should this be interpreted? The options are
That particular online compiler is not generating a valid luac.
The nginx/lua combo does not understand that particular luac.
I should mention that I am using Nginx 1.6.2 on Ubuntu 14.10 (64 bit). I installed Lua enabled Nginix via apt-get install nginx-extras.
I am a beginner here.
Compiling lua for nginx has some specifics. You could see details on official Lua module page http://wiki.nginx.org/HttpLuaModule#Lua.2FLuaJIT_bytecode_support

Chef Nginx cookbook - override version number

I have developed a cookbook for my application which depends on Nginx cookbook. I have downloaded the Nginx cookbook from the following location
https://github.com/miketheman/nginx
and tried including the default recipe in my cookbook and overriding version attribute specified in the default attribute file. But irrespective of what i do, Nginx version 1.0.x is installed. I could not track from where it is fetching the version information. Can anyone help resolving this issue?
Thanks
If you specify the nginx cookbook as a dependency in your own wrapper cookbook, you have to deal with the strict load order of attribute files. Since Chef 11, all dependency cookbooks are loaded first, before the cookbook which requires them. As the dependency cookbooks (including nginx) are loaded, the attribute files are loaded and evaluated in this order:
attributes/default.rb of nginx
all other attributes files of nginx in alphabetical order
attributes/default.rb of your cookbook
all other attributes files of your cookbook in alphabetical order
As you can see, all the attributes of the nginx cookbook are initialized before your own attribute files are loaded. Thus, any dependent attributes (i.e. ones which are initializes using values of other existing attributes) use the values defined in the nginx cookbook, not your own.
Now, as you can see node['nginx']['source']['version'] is initialized with node['nginx']['version'] and thus uses the default value. This value is not changed if you just change node['nginx']['version'] later in your cookbook.
But fear not, there is a remedy :) You can reload specific attribute files in order to re-set their attributes. Here, this is rather convenient if you want to overwrite the nginx version. This is what I do in the attributes/default.rb in my nginx wrapper cookbook:
override['nginx']['version'] = '1.6.0'
override['nginx']['source']['checksum'] = '943ad757a1c3e8b3df2d5c4ddacc508861922e36fa10ea6f8e3a348fc9abfc1a'
# Reload nginx::source attributes with our updated version
node.from_file(run_context.resolve_attribute('nginx', 'source'))
from attributes/default.rb the default version is set to '1.4.4'
The simplest way to find out what version you've set it to is look for the following attribute on the chef-server UI:
['nginx']['version']
hopefully this should be set to whatever you've set it to!
I think that the real issue here is that the ['nginx']['version'] does not behave as you might expect it to.
According to the README file ...
If you use the nginx::default or nginx::repo recipes, you will load the latest binary package from either your platform's repository, or from the "stable" repo that is provided by the Nginx maintainers. The version attribute is effectively ignored!!.
The version attribute is only honoured if you use the nginx::source recipe, where it determines the URL of the source archive that is fetched and built.
If you use the nginx::ohai recipe, it updates the version attribute according to the version of Nginx that is currently installed.
Clear yet? If not then:
nginx::default gives you a (typically) old version of Nginx
nginx::repo gives you a (typically) more recent stable version of Nginx
nginx::source is the only recipe that allows you to specify the version of Nginx that you want.
If that doesn't seem to explain what you are seeing ... you need to dive into the recipe source code. The recipe behaviour (e.g. selection of installation repositories) varies across the different platforms / families.

Does Tomcat 7.x require me to set any environment variables?

I am currently reading Head First: Servlet and JSP. They want me to use Tomcat 5.5 (which is almost outdated). Instead I downloaded Tomcat 7.x.
Now, I was following their instructions on writing the first servlet but I think I will have to set some paths. I have set the path for jdk's bin directory so I can compile Java programs from command line, if I want to.
Does Tomcat require me to set any environment variables ?
If so, which? And how ?
Path to my Tomcat home looks like this: D:\Program Files\apache-tomcat-7.0.35-windows-x86\apache-tomcat-7.0.35
Operating System: Windows 7 Home Premium 32 bit
You should only need JAVA_HOME to be set. Look in catalina.bat.
Given that you are on Windows, the file you need to look at is catalina.bat, not catalina.sh which is specific to Unix and Unix-like systems. If you are on cygwin, ignore my advice here and go with catalina.sh.
You need to set classpaths to your servlet-api, jsp-api, el-api, commons-beanutils, then you need to set ant_home, set tomcat_home and catalina_home
For example:
c:/apache-tomcat-7.0.27/run.bat:
set JAVA_HOME=c:\Program Files\Java\jdk1.7.0_07
set PATH="c:\Program Files\Java\jdk1.7.0_07";%PATH%
set CLASSPATH=.;C:\apache-tomcat-7.0.27\lib\servlet-api.jar;C:\apache-tomcat-7.0.27\lib\jsp-api.jar;C:\apache-tomcat-7.0.27\lib\el-api.jar;C:\apache-tomcat-7.0.27\lib\commons-beanutils-1.8.0-BETA
set ANT_HOME=c:\apache-tomcat-7.0.27
set TOMCAT_HOME=C:\apache-tomcat-7.0.27
set CATALINA_HOME=C:\apache-tomcat-7.0.27
C:\apache-tomcat-7.0.27\bin\startup.bat
Another method is to install NetBeans IDE and it will do everything for you- you just click RUN to run your Project

How to use sbt from behind proxy?

How do I configure sbt to use a proxy?
For example, my build definition needs to connect to GitHub, specifying connection parameters for http.proxy, http.proxyPort, user, and password.
How would I pass in these settings to sbt?
Is there an easy way to switch between proxy/no-proxy settings for when I work from home?
sbt respects the usual environment variables for http proxy settings:
export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=yourserver -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password"
(That's of course, assuming Unix (Linux/OSX etc). On windows you could just set the same environment variable (%JAVA_OPTS%) as usual in the Windows way.)
Then run sbt as usual:
sbt
Switching between proxy/no-proxy should be a matter of setting up a little script that you can 'slurp' in whenever you need it.
Gotchas
Don't include "http://" in the yourserver value
Don't include the port in the yourserver value
You probably also want to include https.proxyHost and https.proxyPort since a lot of stuff works over https
If your proxy requires authentication, don't even bother trying unless it just uses Basic Authentication as SBT doesn't support anything else. Also always beware clear texting credentials into environment variables! Be sure to remove the commands from your .bash_history using a text editing method that won't create trace files (technically you should shred or srm the entire file). If you are on Windows, don't worry about it, your security is already messed up you can't do any more harm.
sbt works in a fairly standard way comparing to the way other JVM-based projects are usually configured.
sbt is in fact two "subsystems" - the launcher and the core. It's usually xsbt.boot.Boot that gets executed before the core starts up with the features we all know (and some even like).
It's therefore a matter of how you execute sbt that says how you could set up a proxy for HTTP, HTTPS and FTP network traffic.
The following is the entire list of the available properties that can be set for any Java application, sbt including, that instruct the Java API to route communication through a proxy:
http_proxy
http_proxy_user
http_proxy_pass
http.proxyHost
http.proxyPort
http.proxyUser
http.proxyPassword
Replace http above with https and ftp to get the list of the properties for the services.
Some sbt scripts use JAVA_OPTS to set up the proxy settings with -Dhttp.proxyHost and -Dhttp.proxyPort amongst the others (listed above). See Java Networking and Proxies.
Some scripts come with their own way of setting up proxy configuration using the SBT_OPTS property, .sbtopts or (only on Windows) %SBT_HOME%\conf\sbtconfig.txt. You can use them to specifically set sbt to use proxies while the other JVM-based applications are not affected at all.
From the sbt command line tool:
# jvm options and output control
JAVA_OPTS environment variable, if unset uses "$java_opts"
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
.sbtopts if this file exists in the current directory, it is
prepended to the runner args
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
-Dkey=val pass -Dkey=val directly to the java runtime
-J-X pass option -X directly to the java runtime
(-J is stripped)
-S-X add -X to sbt's scalacOptions (-S is stripped)
And here comes an excerpt from sbt.bat:
#REM Envioronment:
#REM JAVA_HOME - location of a JDK home dir (mandatory)
#REM SBT_OPTS - JVM options (optional)
#REM Configuration:
#REM sbtconfig.txt found in the SBT_HOME.
Be careful with sbtconfig.txt that just works on Windows only. When you use cygwin the file is not consulted and you will have to resort to using the other approaches.
I'm using sbt with the following script:
$JAVA_HOME/bin/java $SBT_OPTS -jar /Users/jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jars/sbt-launch.jar "$#"
The point of the script is to use the latest version of sbt built from the sources (that's why I'm using /Users/jacek/.ivy2/local/org.scala-sbt/sbt-launch/$SBT_LAUNCHER_VERSION-SNAPSHOT/jars/sbt-launch.jar) with $SBT_OPTS property as a means of passing JVM properties to the JVM sbt uses.
The script above lets me to set proxy on command line on MacOS X as follows:
SBT_OPTS="-Dhttp.proxyHost=proxyhost -Dhttp.proxyPort=9999" sbt
As you can see, there are many approaches to set proxy for sbt that all pretty much boil down to set a proxy for the JVM sbt uses.
In windows environment simply add following line in the sbt/sbtconfig.txt
-Dhttp.proxyHost=PROXYHOST
-Dhttp.proxyPort=PROXYPORT
-Dhttp.proxyUser=USERNAME
-Dhttp.proxyPassword=XXXX
or the Https equivalent (thanks to comments)
-Dhttps.proxyHost=PROXYHOST
-Dhttps.proxyPort=PROXYPORT
-Dhttps.proxyUser=USERNAME
-Dhttps.proxyPassword=XXXX
I used (this is a unix environment) :
export SBT_OPTS="$SBT_OPTS -Dhttp.proxyHost=myproxy-Dhttp.proxyPort=myport"
This did not work for my setup :
export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=myproxy-Dhttp.proxyPort=myport"
In sbt.sh file :
JAVA_OPTS environment variable, if unset uses "$java_opts"
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
But apparently SBT_OPTS is used instead of JAVA_OPTS
For Windows users, enter the following command :
set JAVA_OPTS=-Dhttp.proxySet=true -Dhttp.proxyHost=[Your Proxy server] -Dhttp.proxyPort=8080
To provide one answer that will work for all Windows-users:
Add the following to your sbtconfig.txt (C:\Program Files (x86)\sbt\conf)
-Dhttp.proxyHost=XXXXXXX -Dhttp.proxyPort=YYYY -Dhttp.proxySet=true -Dhttps.proxyHost=XXXXXXX -Dhttps.proxyPort=YYYY -Dhttps.proxySet=true
Replace both XXXXXXX with your proxyHost, and both YYYY with your proxyPort.
If you get the error "Could not find or load main class" you need to set your JAVA_HOME:
set JAVA_HOME=C:\Progra~1\Java\jdkxxxxxx
When on 64-bit windows, use:
Progra~1 = 'Program Files'
Progra~2 = 'Program Files(x86)'
Add both http and https configuration:
export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=yourserver -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password"
export JAVA_OPTS="$JAVA_OPTS -Dhttps.proxyHost=yourserver -Dhttps.proxyPort=8080 -Dhttps.proxyUser=username -Dhttps.proxyPassword=password"
(https config is must, since many urls referred by the sbt libraries are https)
In fact, I even had an extra setting 'http.proxySet' to 'true' in both configuration entries.
When I added the proxy info to the %JAVA_OPTS%, I got an error "-Dhttp.proxyHost=yourserver was unexpected at this time". I put the proxy info in %SBT_OPTS% and it worked.
Using
sbt -Dhttp.proxyHost=yourServer-Dhttps.proxyHost=yourServer -Dhttp.proxyPort=yourPort -Dhttps.proxyPort=yourPort
works in Ubuntu 15.10 x86_64 x86_64 GNU/Linux.
Replace yourServer by the proper address without the http:// nor https:// prefixes in Dhttp and Dhttps, respectively. Remember to avoid the quotation marks. No usr/pass included in the code-line, to include that just add -Dhttp.proxyUser=usr -Dhttp.proxyPassword=pass with the same typing criteria. Thanks #Jacek Laskowski!.
Cheers
I found an item on the FAQ section of Lightbend Activator useful. I am using Activator, which in turn uses SBT, so not sure if this helps users with just SBT, but if you use Activator, like me, and are behind a proxy, follow the instructions in the "Behind A Proxy" section of the FAQ:
https://www.lightbend.com/activator/docs
Just in case the content disappears, here's a copy-paste:
When running activator behind a proxy, some additional configuration
is needed. First, open the activator configuration file, found in your
user home directory under ~/.activator/activatorconfig.txt. Note that
this file may not exist. Add the following lines (one option per
line):
-Dhttp.proxyHost=PUT YOUR PROXY HOST HERE
-Dhttp.proxyPort=PUT YOUR PROXY PORT HERE
-Dhttp.nonProxyHosts="localhost|127.0.0.1"
-Dhttps.proxyHost=PUT YOUR HTTPS PROXY HOST HERE
-Dhttps.proxyPort=PUT YOUR HTTPS PROXY PORT HERE
-Dhttps.nonProxyHosts="localhost|127.0.0.1"
SBT use both HTTP/HTTPS/SFTP/SSH and other kind of connections to a repository. so when behind a proxy, these protocols should be available.
In most simple cases on Windows, you just need to pass proxy parameters options to JVM, like:
java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=8080
That will do.
But if not, there are few things you should be aware of:
whether if you are making a HTTPS connection to the repository.
whether sever certificates been imported to jre cacerts
whether your proxy would replace your server certificates
to solve first, you should pass https proxy parameter to jvm, like:
java -Dhttps.proxyHost=myproxy -Dhttps.proxyPort=8080 -Djavax.net.ssl.trustStore=${TRUST_STORE_PATH}
to solve the second, you should import the ca. there are a lot of tips.
to solve the third, you maybe could considering using a authentication proxy.
to Simplify the config of SBT, it provide sbtconfig.txt and sbtops in the conf directory, look into it.
Reference:
http://www.scala-sbt.org/0.13/docs/Setup-Notes.html
http://www.scala-sbt.org/1.0/docs/Publishing.html
On Mac OS X / El Capitan you can set java environment variables:
$launchctl setenv _JAVA_OPTIONS "-Dhttp.proxyHost=192.168.1.54 -Dhttp.proxyPort=9999"
I found that starting IntelliJ IDEA from terminal let me connect and download over the internet. To start from terminal, type in:
$ idea
Try providing the proxy details as parameters
sbt compile -Dhttps.proxyHost=localhost -Dhttps.proxyPort=port -Dhttp.proxyHost=localhost -Dhttp.proxyPort=port
If that is not working then try with JAVA_OPTS
(non windows)
export JAVA_OPTS = "-Dhttps.proxyHost=localhost -Dhttps.proxyPort=port -Dhttp.proxyHost=localhost -Dhttp.proxyPort=port"
sbt compile
or
(windows)
set JAVA_OPTS = "-Dhttps.proxyHost=localhost -Dhttps.proxyPort=port -Dhttp.proxyHost=localhost -Dhttp.proxyPort=port"
sbt compile
if nothing works then set SBT_OPTS
(non windows)
export SBT_OPTS = "-Dhttps.proxyHost=localhost -Dhttps.proxyPort=port -Dhttp.proxyHost=localhost -Dhttp.proxyPort=port"'
sbt compile
or
(windows)
set SBT_OPTS = "-Dhttps.proxyHost=localhost -Dhttps.proxyPort=port -Dhttp.proxyHost=localhost -Dhttp.proxyPort=port"
sbt compile
If you are using a Proxy which requires authentication, I have a solution for you :)
As #Faiz explained above, SBT has a very hard time handling proxy requiring authentication. The solution is to bypass this authentication, if you cannot turn off your proxy on demand (corporate proxy for example).
To do so, I suggest you use a squid proxy, and configure it with your username and password to access your corporate proxy. See : https://doc.ubuntu-fr.org/squid
Then, you can set JAVA_OPTS or SBT_OPTS environment variables so that SBT connects to your own local squid proxy instead of your corporate proxy :
export JAVA_OPTS = "-Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128"
(just c/c this in your bashrc without modifying anything and it should work fine).
The trick is that Squid Proxy does not require any authentication, and acts as an intermediate between SBT and your other proxy.
If you have troubles in applying this advise, please let me know.
Regards,
Edgar
For those still landing on this thread trying to find where/how to configure HTTP proxy in IntelliJ, here's how I managed to get it to work for me. I hope this helps!
(Note: specify your network username and password in the corresponding boxes):-

Resources