Skip to content

Instantly share code, notes, and snippets.

@rlefevre
Last active March 23, 2020 13:48
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rlefevre/7c21513c3cc14ea23524223ab35e4ca6 to your computer and use it in GitHub Desktop.
Save rlefevre/7c21513c3cc14ea23524223ab35e4ca6 to your computer and use it in GitHub Desktop.
Elm using elm.dmy.fr proxies

Update: As package.elm-lang.org IP address has been changed and is not blocked anymore as far as I know, these proxies have been disabled. If you still need them, add a comment describing why.


Here is how to use the proxies:

Packages documentation

Two options:

1. Browse elm.dmy.fr instead of package.elm-lang.org

This requires no configuration, but this won't redirect google results or absolute links.

For elm < 0.19, use old.elm.dmy.fr instead.

2. Automatic proxy configuration URL

Configure your system and/or browser proxy with the following proxy automatic configuration URL:

https://elm.dmy.fr/proxy.pac

Or add in your own configuration:

        if (shExpMatch(host, "package.elm-lang.org"))
        {
                return "PROXY elm.dmy.fr:9999";
        }

This will only redirects package.elm-lang.org so performance won't be impacted for other web sites. This should work for all documentation links, including google results.

elm binary

Again two options:

1. https_proxy

$ https_proxy=elm.dmy.fr:9999 elm <command> ...

As the proxy only accepts domains used by the elm binary, don't set it globally, or it could break other programs.

If you don't want to type it each time, wrap the installed elm binary in a shell script found in your $PATH before the the real one. For example if you installed elm with npm:

#!/bin/sh

https_proxy=elm.dmy.fr:9999 ~/.local/bin/elm "$@"

For elm < 0.19, use http_proxy instead:

http_proxy=elm.dmy.fr:9999 elm-make [...]
http_proxy=elm.dmy.fr:9999 elm-package ...

2. Rebuild the elm binary to use the proxy

By rebuilding the binary with a single line modification, you can avoid having to set the https_proxy variable. I won't provide a binary for security and maintenance reasons, but you can use this Dockerfile (using this guide if needed, just changing the Dockerfile) to build an Elm 0.19.0 static Linux x64 one with one command in a few minutes.

Privacy

The proxies log IP addresses to allow to ban some if there are some abuses unrelated to Elm. Logs are deleted after a few days.

@AntonRich
Copy link

How do I wrap the elm binary? Never done that before.
I tied to execute it as a script it didn't work.
#!/bin/sh

https_proxy=elm.dmy.fr:9999 ~/.local/bin/elm "$@"

@rlefevre
Copy link
Author

rlefevre commented Aug 21, 2019

Your system configuration may be different.

  • Install elm globally if you have not done it already: npm install -g elm
  • Run which elm and use the output instead of ~/.local/bin/elm in the script.
  • Name the script file elm
  • Add execution permissions to the script: chmod +x ./elm
  • Put the script in a bin directory listed in echo $PATH before the one returned by which elm
  • Open a new shell and check that elm commands use the proxy

If you don't know where to put the script, you could for example put in in ~/bin:

$ mkdir -p ~/bin
$ mv elm ~/bin/
$ echo 'export PATH=~/bin:$PATH' >> ~/.bashrc

then open a new shell or terminal and check that the elm command works and uses your script by running which elm, it should now return your script location. elm commands should now use the proxy.

Note that this only works for elm installed globally (npm install -g elm). If you install it locally in a project with npm install elm and run npx elm, it won't use your script. You would have to use https_proxy=elm.dmy.fr:9999 npx elm ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment