Friday Repost: Making Grails work behind an proxy server

The Friday Repost series are copies from my earlier writings. Since I don’t want to loose them, and they might prove useful to others, I’m reposting them on this blog.

Making Grails work behind an NTLM firewall (or using Grails without Internet)

Currently, I’m in the process of taking over an existing Grails project and migrating it to a different location. This location has been setup by me, so I have full control over it, except for one tiny detail: the Proxy Server.

The application used to work great, and installing plugins was a breeze: just do a good old ‘grails install-plugin fitnesse’, and the plugin would be installed. However, since this Proxy Server is not just any Proxy Server, but a Microsoft NTLM Proxy Server, we tried quite hard to make Java work with it, but at the moment the score is 1-0 for the Proxy Server. This gives us the following problems:

1) Our dependencies cannot be downloaded
2) Our plugins cannot be be downloaded
3) Some plugins cannot be installed anymore

Downloading dependencies
In our BuildConfig.groovy, we specified some dependencies like joda time and xstream. These dependencies are normally downloaded, but due to our Proxy issue, that doesn’t work.

Our solution to this is to use Nexus. Nexus is able to pass the firewall, and can download our dependencies. It serves as a transparent Maven proxy, which can also be used by Ivy, and solves our problem nicely. Besides, it’s a good idea to install a local Maven proxy anyway, mostly because of reliability, but also because of speed and making sure everyone uses the same dependencies.

Downloading plugins
Unfortunately, the Grails plugins are not in a Maven repository. However, a solution to this is to download the plugin zip (eg, rename it (to, put it in the lib directory (even though I’m really not a fan of putting binaries in version control systems), and register it in the and BuildConfig.groovy.

The BuildConfig.groovy should look like this:

As you can see, everything is configured here: the dependencies are here, the location to nexus is configured, and there’s a plugin closure. This “plugins” closure defines the plugins, and allows you to place them in the ‘lib’ directory. Be sure to rename the plugin zip to remove the ‘grails’ part, else it doesn’t work. Maybe these zips are also available from a Maven repository, which would solve the issue of putting binaries in our source control system, but I haven’t been able to find them yet.

Plugin installation
Some plugins, like the jQuery plugin, but also like my own plugin, the syntax-highlighter, download resources from the Internet when installing them. I haven’t been able to work around that yet, but my current solution is to just not use those plugins. I downloaded the jQuery javascript libraries and attached them to the project myself, and since we only use jQuery which does that, this solution is also an adequate fix.

So, as you can see, with some effort, it’s possible to make Grails work behind a Proxy Server, or without internet at all. This is a good solution for build servers, so you can have reproducible builds without the need for an Internet connection.

8 replies
  1. Gethin James
    Gethin James says:

    I download the Grails pluglins, then manually install them in our local Maven repo – in your case Nexus. Then you don’t need to mess about with putting things in the lib directory.

    Also “inherit false” works better for BuildConfig.groovy

    • Erik Pragt
      Erik Pragt says:

      Based on the tweet, it’s a bit hard to say what it does. Do you have more information? Does it mean that no dependency resolution would be done? Cause that would be a nice improvement in startup time.

  2. Leo
    Leo says:

    We are also behind corporate proxy server but common grails proxy settings work fine in our case. We have something like the following in ProxySettings.groovy

    myproxy=[“http.proxyHost”:”companyproxyserver”, “http.proxyPort”:”8080″, “http.proxyUserName”:”myuser”, “http.proxyPassword”:”mypassword”]

    Have you tried similar config in your case?

      • Erik Pragt
        Erik Pragt says:

        Hi Siva, I’m sorry, but I have no experience with .pac files. I know you can open them, they are just txt files, and with a bit luck, depending on the complexity of the pac, you might be able to find the correct configuration there.

Comments are closed.