Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*~
vendor
glide.lock
dist
.idea
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: [email protected]:SDFE/sd-precommit.git
rev: v1.2.4
hooks:
- id: sd-hooks
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.8.2
hooks:
- id: commitizen
stages: [commit-msg]
- id: commitizen-branch
stages: [pre-push]
7 changes: 2 additions & 5 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
***Note**: versioned dependencies has been removed for simplicity, once we have some experience with vgo & co. we will be adding versioned dependencies back in, however, for now this is sufficient and as of 30/8/2018 the build works*

### requirements
- go 1.10

### known issues
- go 1.11 seems to make the http client `panic` when trying to connect to a endpoint that doesn't exist or the endpoint doesn't listen on that port
- go 1.20

### build it

Expand Down Expand Up @@ -37,4 +34,4 @@ i'd suggest to remove the local image after the build is complete

```
docker rmi local/aws-es-proxy-build:latest
```
```
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
FROM alpine:3.8
LABEL name="aws-es-proxy" version="latest"
FROM golang:1.20-alpine

WORKDIR /go/src/github.com/abutaha/aws-es-proxy
COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o aws-es-proxy

FROM alpine:3.17
LABEL name="aws-es-proxy" \
version="latest"

RUN apk --no-cache add ca-certificates
WORKDIR /home/
COPY dist/linux/aws-es-proxy /usr/local/bin/
COPY --from=0 /go/src/github.com/abutaha/aws-es-proxy/aws-es-proxy /usr/local/bin/

ENV PORT_NUM 9200
EXPOSE ${PORT_NUM}

ENTRYPOINT ["aws-es-proxy"]
CMD ["-h"]
9 changes: 0 additions & 9 deletions Dockerfile.BUILD

This file was deleted.

94 changes: 55 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
# Mendeley changes

## Build

see: [BUILD.md](BUILD.md)

## Logging

- removed log to file
- now using `go-kit` for logging with levels

## Redirects

- implemented changes from PR (https://github.com/abutaha/aws-es-proxy/pull/31)
# SDFE changes

- Remove the setting of the Endpoint on command line, and instead use the HTTP header X-ES-Endpoint header

# aws-es-proxy

[![Docker Pulls](https://img.shields.io/docker/pulls/abutaha/aws-es-proxy.svg)](https://hub.docker.com/r/abutaha/aws-es-proxy/)

**aws-es-proxy** is a small web server application sitting between your HTTP client (browser, curl, etc...) and Amazon Elasticsearch service. It will sign your requests using latest [AWS Signature Version 4](http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) before sending the request to Amazon Elasticsearch. When response is back from Amazon Elasticsearch, this response will be sent back to your HTTP client.

Kibana requests are also signed automatically.
Expand All @@ -28,28 +18,36 @@ Kibana requests are also signed automatically.

Download the latest [aws-es-proxy release](https://github.com/abutaha/aws-es-proxy/releases/).

### Docker

There is an official docker image available for aws-es-proxy. To run the image:

```sh
# v0.9 and newer (latest always point to the latest release):

docker run --rm -v ~/.aws:/root/.aws -p 9200:9200 abutaha/aws-es-proxy:v1.0 -endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com -listen 0.0.0.0:9200

v.08:

docker run --rm -it abutaha/aws-es-proxy ./aws-es-proxy -endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com

```

To expose a port number other than the default 9200, pass an environment variable of `PORT_NUM` to docker with the port number you wish to expose for your service.

### Via homebrew

```sh
brew install aws-es-proxy
```


### Build from Source

#### Dependencies:
* go1.5+
* [glide package manager](https://github.com/Masterminds/glide)

* go1.14+

```sh
#requires go1.5
export GO15VENDOREXPERIMENT=1
mkdir -p $GOPATH/src/github.com/abutaha
cd $GOPATH/src/github.com/abutaha
git clone https://github.com/abutaha/aws-es-proxy
cd aws-es-proxy
glide install
#requires go1.14
go build github.com/abutaha/aws-es-proxy
```

Expand Down Expand Up @@ -92,11 +90,20 @@ export AWS_SECRET_ACCESS_KEY=MY-SECRET-KEY

## Usage example:

You can use either argument `-endpoint` OR environment variable `ENDPOINT` to specify AWS ElasticSearch endpoint.

```sh
./aws-es-proxy -endpoint https://test-es-somerandomvalue.eu-west-1.es.amazonaws.com
Listening on 127.0.0.1:9200
```

```sh
export ENDPOINT=https://test-es-somerandomvalue.eu-west-1.es.amazonaws.com

./aws-es-proxy -listen 10.0.0.1:9200 -verbose
Listening on 10.0.0.1:9200
```

*aws-es-proxy* listens on 127.0.0.1:9200 if no additional argument is provided. You can change the IP and Port passing the argument `-listen`

```sh
Expand All @@ -121,6 +128,10 @@ For a full list of available options, use `-h`:
```sh
./aws-es-proxy -h
Usage of ./aws-es-proxy:
-auth
Require HTTP Basic Auth
-debug
Print debug messages
-endpoint string
Amazon ElasticSearch Endpoint (e.g: https://dummy-host.eu-west-1.es.amazonaws.com)
-listen string
Expand All @@ -129,28 +140,33 @@ Usage of ./aws-es-proxy:
Log user requests and ElasticSearch responses to files
-no-sign-reqs
Disable AWS Signature v4
-password string
HTTP Basic Auth Password
-pretty
Prettify verbose and file output
-realm string
Authentication Required
-remote-terminate
Allow HTTP remote termination
-timeout int
Set a request timeout to ES. Specify in seconds, defaults to 15 (default 15)
-username string
HTTP Basic Auth Username
-verbose
Print user requests
-version
Print aws-es-proxy version
```

## Docker

There is an official docker image avaiable for aws-es-proxy. To run the image:

```sh
# Prints usage info (-h)
docker run --rm -it abutaha/aws-es-proxy

# Runs with custom command/args
docker run --rm -it abutaha/aws-es-proxy ./aws-es-proxy -endpoint https://dummy-host.ap-southeast-2.es.amazonaws.com
```

To expose a port number other than the default 9200, pass an environment variable of `PORT_NUM` to docker with the port number you wish to expose for your service.

## Using HTTP Clients

After you run *aws-es-proxy*, you can now open your Web browser on [http://localhost:9200](http://localhost:9200). Everything should be working as you have your own instance of ElasticSearch running on port 9200.

To access Kibana, use [http://localhost:9200/_plugin/kibana/](http://localhost:9200/_plugin/kibana/)
To access Kibana, use [http://localhost:9200/_plugin/kibana/app/kibana](http://localhost:9200/_plugin/kibana/app/kibana)

## Pre-commit
Install with:
```bash
pre-commit install --hook-type pre-commit --hook-type commit-msg --hook-type pre-push
```
Loading