Skip to content

Commit

Permalink
configure nginx caching
Browse files Browse the repository at this point in the history
  • Loading branch information
zfletch committed Feb 29, 2020
1 parent b9448c3 commit 7775a4d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
morph:
image: perseidsproject/morpheus-perseids-api:v2.0.0
ports:
- "1316:1316"
- "1500:1500"
```
The port can be customized using the environment variable `PORT` and the application
Expand Down Expand Up @@ -74,7 +74,7 @@ MORPHLIB=/path/to/stemlib EXECUTABLE=/path/to/morpheus bundle exec ruby app.rb

### Examples

`http://localhost:1316/raw/greek/a)%2Fnqrwpos`:
`http://localhost:1500/raw/greek/a)%2Fnqrwpos`:

```xml
<words>
Expand Down Expand Up @@ -104,7 +104,7 @@ MORPHLIB=/path/to/stemlib EXECUTABLE=/path/to/morpheus bundle exec ruby app.rb
</words>
```

`http://localhost:1316/raw/latin/cactus`:
`http://localhost:1500/raw/latin/cactus`:

```xml
<words>
Expand Down Expand Up @@ -134,7 +134,7 @@ MORPHLIB=/path/to/stemlib EXECUTABLE=/path/to/morpheus bundle exec ruby app.rb
</words>
```

`http://localhost:1316/raw/greek/a)%2Fnqrwpos?verbose=true`:
`http://localhost:1500/raw/greek/a)%2Fnqrwpos?verbose=true`:

```xml
<words>
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.no-redis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ services:
volumes:
- .:/app
ports:
- 1316:1316
- 1500:1500
13 changes: 11 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ services:
volumes:
- .:/app
ports:
- 1316:1316
- 1500:1500
depends_on:
- redis
environment:
- REDIS_ENABLED=true
- REDIS_URL=redis://redis:6379
redis:
image: redis:5.0.5
image: redis:5.0.7
ports:
- 6379:6379
cache:
image: nginx:1.17.8
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./tmp/nginx:/var/cache/nginx
ports:
- 1501:1501
depends_on:
- web
2 changes: 1 addition & 1 deletion lib/config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Config
MORPHLIB = ENV.fetch('MORPHLIB') { '/morpheus/stemlib' }
EXECUTABLE = ENV.fetch('EXECUTABLE') { '/morpheus/bin/morpheus' }
PORT = ENV.fetch('PORT') { '1316' }
PORT = ENV.fetch('PORT') { '1500' }
EXPIRY = ENV.fetch('EXPIRY') { '604800' }
REDIS_ENABLED = ENV.fetch('REDIS_ENABLED') { 'false' }
REDIS_URL = ENV.fetch('REDIS_URL') { 'redis://127.0.0.1:6379/0' }
Expand Down
24 changes: 24 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
events { }

http {
proxy_cache_path /opt/cache/ keys_zone=cache:10m max_size=10g inactive=12h;

server {
listen 1501;
listen [::]:1501;

server_name localhost;

location / {
proxy_cache cache;
proxy_cache_key $scheme$proxy_host$request_uri$http_accept;
proxy_cache_min_uses 2;
proxy_cache_valid any 7d;

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET';

proxy_pass http://web:1500/;
}
}
}

0 comments on commit 7775a4d

Please sign in to comment.