From da1aefe45efe01eaebf0c209c952b5bdfc119699 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Thu, 18 Jan 2018 12:15:07 +0100 Subject: [PATCH] #20 add notes about using a reverse proxy (e.g. nginx) --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 078674d7b0..9e3264a6b9 100644 --- a/README.md +++ b/README.md @@ -1019,3 +1019,37 @@ mysql> source path_to/xmysql/tests/sample.sql ``` $ mocha tests/*.js --exit ``` + +# Reverse Proxy + +This is a config example when you use nginx as reverse proxy + +``` +events { + worker_connections 1024; + +} +http { + server { + server_name 127.0.0.1; + listen 80 ; + location / { + rewrite ^/(.*) /$1 break; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:3000; + } + } +} +``` + +e.g. + +0. create a docker network `docker network create local_dev` +1. start a mysql server `docker run -d --name mysql -p 3306:3306 --network local_dev -e MYSQL_ROOT_PASSWORD=password mysql` +2. start xmysql `docker run -d --network local_dev --name xmyxql -e DATABASE_NAME=sys -e DATABASE_HOST=mysql -p 3000:80 markuman/xmysql:0.4.2` +3. start nginx on host system with the config above `sudo nginx -g 'daemon off;' -c /tmp/nginx.conf` +4. profit `curl http://127.0.0.1/api/host_summary_by_file_io_type/describe` + +When you start your nginx proxy in a docker container too, use as `proxy_pass` the `--name` value of xmysql. E.g. `proxy_pass http://xmysql` (remember, xmysql runs in it's docker container already on port 80). \ No newline at end of file