Browse Source

tried reverse proxying with nginx to get around cross domain security problemen with basex, not working

Bachir Soussi Chiadmi 4 years ago
parent
commit
77c68f4dd5
6 changed files with 97 additions and 0 deletions
  1. 7 0
      Docker/nginx/Dockerfile
  2. 3 0
      Docker/nginx/bashrc
  3. 49 0
      Docker/nginx/default.conf
  4. 13 0
      Docker/nginx/index.html
  5. 2 0
      Docker/nginx/inputrc
  6. 23 0
      docker-compose.yml

+ 7 - 0
Docker/nginx/Dockerfile

@@ -0,0 +1,7 @@
+FROM nginx:latest
+
+COPY ./bashrc /root/.bashrc
+COPY ./inputrc /root/.inputrc
+COPY ./index.html /var/www/html/index.html
+# COPY ./default.conf /etc/nginx/conf.d/default.conf
+COPY ./default.conf /etc/nginx/nginx.conf

+ 3 - 0
Docker/nginx/bashrc

@@ -0,0 +1,3 @@
+PS1='\e[36m\e[1mNGINX\e[0m:\e[90m\w\e[0m\n$ '
+bind '"\e[A": history-search-backward'
+bind '"\e[B": history-search-forward'

+ 49 - 0
Docker/nginx/default.conf

@@ -0,0 +1,49 @@
+worker_processes 1;
+
+events { worker_connections 1024; }
+
+http {
+  upstream docker-api {
+      server basex:8984;
+  }
+  upstream docker-client {
+      server client:8988;
+  }
+
+  proxy_set_header   Host $host;
+  proxy_set_header   X-NginX-Proxy true;
+  proxy_set_header   X-Real-IP $remote_addr;
+  proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
+  proxy_set_header   X-Forwarded-Host $server_name;
+
+  server {
+      listen 80;
+      root /var/www/html;
+      index index.html;
+      charset utf-8;
+      server_name dev.gdp.fr;
+
+      access_log on;
+      error_log  /var/log/nginx/error.log error;
+
+      sendfile off;
+
+      client_max_body_size 100m;
+
+      location / {
+          try_files $uri $uri/ index.html;
+      }
+
+      location /api {
+        rewrite ^/api/(.*) /$1 break;
+        proxy_redirect off;
+        proxy_pass http://docker-api;
+      }
+
+      location /client {
+        rewrite ^/client/(.*) /$1 break;
+        proxy_redirect off;
+        proxy_pass http://docker-client;
+      }
+  }
+}

+ 13 - 0
Docker/nginx/index.html

@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+  <head>
+    <meta charset="utf-8">
+    <title>Proxy</title>
+  </head>
+  <body>
+    <ul>
+      <li><a href="/api">api</a></li>
+      <li><a href="/client">client</a></li>
+    </ul>
+  </body>
+</html>

+ 2 - 0
Docker/nginx/inputrc

@@ -0,0 +1,2 @@
+set show-all-if-ambiguous on
+set completion-ignore-case on

+ 23 - 0
docker-compose.yml

@@ -12,6 +12,8 @@ services:
       - 1984:1984
       - 8984:8984
     working_dir: "/srv/basex"
+    networks:
+      - api
 
   client:
     build: ./Docker/client
@@ -23,7 +25,28 @@ services:
     working_dir: "/app"
     depends_on:
       - basex
+    networks:
+      - client
+
+  nginx:
+    build: ./Docker/nginx/
+    ports:
+      - 8999:80
+    volumes:
+      - "${LOG_ROOT}:/var/log:rw"
+    # working_dir: "/var/www/html"
+    depends_on:
+      - basex
+      - client
+    networks:
+      - api
+      - client
+
 
 volumes:
   basex-home:
   # client-home:
+
+networks:
+  api:
+  client: