Giter Club home page Giter Club logo

infrastructure's People

Contributors

danielcompton avatar hellonico avatar hypirion avatar kahunamoore avatar spencercrissman avatar tobias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

infrastructure's Issues

Setup fail2ban to block people who hit the Clojars repo too much

There are some people with misconfigured applications/Nexus repo's who request files way too much. It could be good to use fail2ban to stop them from making requests too often. A first approximation for detecting this would be to check for IP's downloading the same file more than 5 times in half an hour. There are a few things to consider here:

  • The larger the time window, the more memory this will consume
  • If we're going to move to a CDN, how will we handle misconfigured clients like this? Maybe we can analyse the logs and block IPs out of band?
  • We don't want to block normal users, it should probably be run in report only mode for a while to make sure it's calibrated correctly.
  • It would be good to build up profiles of what normal maven usage and abusive behaviour look like, as kicking off a build with a clean m2 will generate a lot of (valid) requests.

http://codelog.climens.net/2011/02/13/using-fail2ban-with-nginx-in-debian/
http://blog.teabough.com/fail2ban-api-mailjet/

Change license to MIT

We would like to change the license to MIT. This would make it possible for people to derive new works from this config for internal purposes without having to redistribute them. Under normal usage, sharing the changes would not be required, but it would if you distributed it (e.g. as part of a package that runs on client sites)

To allow for the relicensing, reply to this issue with "I Agree". If you don't agree then feel free to discuss this more here.

Thanks!

Zero downtime deploys

Related to #3, it could be good to have zero downtime deploys where the second Java process gets brought up online before shutting down the first one. Possibly could use Nginx to switch between them. However there were issues in the past with running multiple processes against a single sqlite db, so this might not be a good idea in the short term.

Fix include deprecation warnings

[DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated. Use
'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions. This feature
 will be removed in a future release. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: include is kept for backwards compatibility but usage is discouraged.
 The module documentation details page may explain more about this rationale.. This feature
will be removed in a future release. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.

We use include in a few places. [import_tasks](https://docs.ansible.com/ansible/devel/modules/import_tasks_module.html) seems like the correct thing to use for us but

  • It is still marked as a preview without a backwards compatible interface (?!)
  • It's not clear if/how we can use sudo when running those tasks

Any expert Ansible help on the 'correct' thing to do here would be welcome.

SSL for site

I'm pretty sure I've setup SSL correctly (by copying from the previous server), but it would be good to get another set of eyes over it to make sure it's correct and is up to date with best practices, particularly over the IPv6 stuff.

Add manual steps instructions

  • Adding users still requires manually adding authorised keys
  • Bootstrapping a server requires logging in, adding an audible user, and adding them as a sudoer
  • nginx seems to need a restart after the initial bootstrap
  • rsync has a pid problem after initial bootstrap

X-Frame options header

We only put x-frame-options on requests served by the app, so anything that Nginx serves directly (like redirects and resources) doesn't have this header attached. I'm not sure what the security implications of this are, but worth considering further.

Server hardening

Configure gzip in nginx

clojars.org doesn't seem to be gzipping assets. It would be good to figure out why, as it seems like it should be based on the config.

Fix jinja2 templating warnings

TASK [system : ensure admin user accounts exist] ********************************************
 [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or
{% %}. Found: {{ item.active }}

Figure out what the correct way to do this is instead.

Set server timezone to UTC

It is set to UTC out of the box, but it would be good to make sure it stays like that with an ansible task. This looks promising but needs to have backup turned off.

Decouple dependency on clojars.org when building Clojars uberjar

To build Clojars the app, we need Clojars the site. This is a nasty circular dependency we need to break.

If we're trying to bootstrap a new clojars server, it stands to reason that there may not be a running one in place at the time. There are a few options here for building the app, and two main scenarios to think about: rebuilding the server from scratch when there is no Clojars server, and everyday deployments.

Use a mirror for building Clojars on the clojars server

We can set a mirror in the Leiningen config, and use this for both building from scratch, and everyday builds.

Pros:

  • Minimal changes to current build system required
  • JAR will still be built on server, simple to understand
  • Keeps all config in Ansible

Cons:

  • Relies on mirror support to work well in Leiningen
  • We would need to modify the clojars-web project.clj to use these mirrors; currently mirrors in profiles.clj won't work for :plugin-repositories and we need the supersport plugin.
  • Relies on the mirror server/block store to be available at the time we are rebuilding
  • Needs to download all of the JARs at build time for bootstrapping, this can take a while. On an established server this isn't likely to be as big an issue.
  • Takes a while to build and test the JAR
  • Puts some amount of load on the server

Build Clojars locally ahead of time and copy it to the server

I think @tobias is in favour of this option.

Pros:

  • All deps likely to be downloaded so it will be fast in all cases
  • Likely to be building with a machine with more resources than a VPS
  • Pretty simple

Cons:

  • Still needs a mirror available in case the main server is down
  • Kind of gets away from the ansible ideal (I think?) as it relies on local state to have a working build toolchain and it is managed out of band from the rest of the Ansible config. May not be as easily reproducible between different people's machines, e.g. profiles.clj differences.
  • Build scripts would probably need to reach out from their own folders to the other project

Build Clojars on the server ahead of time and write an artifact to S3 or similar

How this would work:

  1. When a new version is ready, an admin would run an ansible play to build the new version on the clojars server (or optionally on a new VM in EC2, but that's probably not necessary).
  2. Once the uberjar is built it is copied into S3 (and another redundant object store?) for deployment.
  3. When it comes to deploy that version (either straight away, or far off in the future) it doesn't rely on any of our infrastructure being up and running.

This is my personal preference as it seems to be the most fault tolerant, however after listing the cons, I'm not so sure it's the right solution.

Pros:

  • Deploys from scratch are much faster as they just need to download a JAR
  • Possibly most fault tolerant design
  • Doesn't rely on a working Clojure environment on the deployers machine
  • Keeps everything in Ansible

Cons:

  • It adds a dependency on the object store
  • It adds additional complexity around orchestration
  • It adds additional complexity keeping more application secrets
  • Requires another account

Thoughts welcome!

Notify yeller for deployments with correct config

We need to make sure we call Yeller with the right config when testing and going in production. It might also be good to disable Yeller entirely when non admins are running the app/ansible scripts.

SSHD config

This needs to be templates in Ansible. Probably only something an admin can do.

Run DB migrations in deploy

I'm not quite sure what do about DB migrations, possibly they should be a resource in the uberjar? That way we always know we've got the right schema for each version.

Install goaccess from custom deb repo

The version of goaccess bundled with ubuntu is ancient. It would be really handy to have the version described in "Official GoAccess' Debian/Ubuntu Repository" from here installed.

Install authorised keys from private folder

Each admin can provide authorised keys to be put against their user account. These need to be installed. They can take the place of the commented out github public keys script in /roles/system/tasks/main.yml.

Make sure rsync is working

I was able to setup rsync to run, but I haven't got this script to run correctly yet.

$ rsync -av --delete  localhost::clojars my-wonderful-copy-of-clojars
rsync: failed to connect to localhost: Connection refused (61)
rsync error: error in socket IO (code 10) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/clientserver.c(105) [receiver=2.6.9]

$ rsync -av --delete  -e 'usr/bin/ssh -p2222' localhost::clojars my-wonderful-copy-of-clojars
rsync: Failed to exec usr/bin/ssh: No such file or directory (2)
rsync error: error in IPC code (code 14) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/pipe.c(86) [receiver=2.6.9]
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(453) [receiver=2.6.9]

I'm not sure if this is an artifact of running through Vagrant on port 2222 or something else is misconfigured.

Upgrade SSL cert to use SHA2 hash and other SSL improvements

https://www.ssllabs.com/ssltest/analyze.html?d=clojars.org&s=173.230.139.200

Essential

  • This server supports weak Diffie-Hellman (DH) key exchange parameters. Grade capped to B. (I think this is unavoidable to support Java 6).
  • Certificate has a weak signature and expires after 2015. Upgrade to SHA2 to avoid browser warnings.
  • This server accepts RC4 cipher, but only with older protocol versions. Grade capped to B. (Need to revise cipher suite for todays best practices). https://cipherli.st

Nice to have

With all of these things, we need to keep in mind the ever present spectre of Java 6 and corporate SSL middleware boxes.

Enable tests in build-clojars script

They were commented out because of a failing test in clojars.test.unit.tools.repair-metadata when run on the server. From memory the file ordering wasn't consistent.

Setup postfix

I've setup the email as best I can from the previous server, but it doesn't seem like it's working yet. I'm not sure if that's just because I'm running on localhost though and it would be fine on a real server? We also need to check the SSL is setup correctly for Postfix.

  • Make postfix send emails
  • Make sure SSL is setup correctly

Log rotation

I'm not quite sure how the Nginx logs get rotated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.