Skip to content

Commit

Permalink
Merge pull request #77 from Wafris/v2-staging
Browse files Browse the repository at this point in the history
v2 Release
  • Loading branch information
mbuckbee authored Jul 17, 2024
2 parents b5e6672 + c08dcbc commit 90fb52e
Show file tree
Hide file tree
Showing 79 changed files with 2,164 additions and 503 deletions.
43 changes: 12 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Wafris for Ruby/Rails
Wafris is an open-source Web Application Firewall (WAF) that runs within Rails (and other frameworks) powered by Redis.

Paired with [Wafris Hub](https://wafris.org/hub), you can create rules to block malicious traffic from hitting your application.
Paired with [Wafris Hub](https://hub.wafris.org), you can view your site traffic in real time and and create rules to block malicious traffic from hitting your application.

![Rules and Graph](docs/rules-and-graph.png)

Expand All @@ -16,10 +16,9 @@ Need a better explanation? Read the overview at: [wafris.org](https://wafris.org

## Installation and Configuration

The Wafris Ruby client is a gem that installs a Rack middleware into your Rails/Sinatra/Rack application that communicates with a Redis instance.
The Wafris Ruby client is a gem that installs a Rack middleware into your Rails/Sinatra/Rack application filtering requests based on your created rules.

### Requirements
- Redis-rb 4.8+
- Rails 5+
- Ruby 2.5+

Expand All @@ -42,40 +41,22 @@ Update your Gemfile to include the Wafris gem and run
gem 'wafris'
```

### 3. Set your Redis Connection

Specify your redis with the following initializer. We recommend storing the Redis URL as an environment variable or in a secret management system of your choosing rather than hard coding the string in the initializer.

```ruby
# Create this file and add the following:
# config/initializers/wafris.rb

if ENV["WAFRIS_REDIS_URL"]
Wafris.configure do |c|
c.redis = Redis.new(
url: ENV["WAFRIS_REDIS_URL"],
timeout: 0.25,
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE },
)
c.redis_pool_size = 25
c.quiet_mode = false
end
end
```
### 3. Set your API Key

For more details and troubleshooting on the initializer, please read our [Wafris Initializer Guide](docs/wafris-initalizer.md).
In your production environment, you'll need to set the `WAFRIS_API_KEY` environment variable to your API key. When you sign up on [Wafris Hub](https://hub.wafris.org), you'll receive your API key along with per-platform instructions.

Not sure what Redis provider to use? Please read our [Wafris Redis Providers Guide](https://wafris.org/guides/redis-provisioning)
## v1 Migration

Version 1 of the Wafris Rails client gem is deprecated. While it will continue to work you will experience signifiant performance improvements moving to v2.

### 4. Deploy your application
The v2 Client does not depend on a Redis instance and instead uses locally sync'd SQLite databases. If you are currently using your own Redis instance, it will continue to work, but we would recommend creating a new WAF instance on Hub and migrating your existing rules.

When deploying your application, you should see the following in your logs:
Update by running `bundle update wafris` and then updating your configuration.

We recommend removing your existing `config/initializers/wafris.rb` file and instead setting the `WAFRIS_API_KEY` environment variable in your production environment.

Your Wafris API key and platform specific instructions are available in the Setup section of your [Wafris Hub](https://hub.wafris.org) dashboard.

```
[Wafris] attempting firewall connection via Wafris.configure initializer.
[Wafris] firewall enabled. Connected to Redis on <host from Redis URL>. Ready to process requests. Set rules at: https://wafris.org/hub
```

## Trusted Proxies

Expand Down
12 changes: 12 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rack'
require 'rack/reloader'

use Rack::Reloader, 0 # 0 means reload on every request

# Encoding defaults
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8

require './lib/wafris/middleware'

run Wafris::Middleware.new
6 changes: 0 additions & 6 deletions lib/lua/.luarc.json

This file was deleted.

305 changes: 0 additions & 305 deletions lib/lua/dist/wafris_core.lua

This file was deleted.

Loading

0 comments on commit 90fb52e

Please sign in to comment.