Docker FIX wrong redirects by moving from apache to nginx
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..874644e
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,16 @@
+# Docker images

+

+## Demo

+- For testing purposes

+- Contains a running virtual netconf device (netopeer2server)

+- Go to the `demo` folder, then type `docker build -t netopeer2gui .`, after it finishes, type `docker run -dp 80:80 netopeer2gui` and go to `http://localhost` in your browser.

+- You can connect to a device using these credentials:

+```

+host: localhost

+port: 830

+username: root

+password: docker

+```

+

+## Production

+- Comming soon
\ No newline at end of file
diff --git a/docker/demo/Dockerfile b/docker/demo/Dockerfile
index 1998988..b9264d6 100644
--- a/docker/demo/Dockerfile
+++ b/docker/demo/Dockerfile
@@ -1,91 +1,91 @@
-FROM ubuntu:18.04

-

-# Install required binaries

-RUN apt-get upgrade && apt-get update -y && apt-get install -y \

-   mongodb python3 python3-dev python3-pip \

-   pkg-config \

-   git cmake clang curl \

-   libpcre3-dev swig \

-   zlib1g-dev libgcrypt-dev libssl-dev \

-   libprotobuf-c-dev protobuf-c-compiler libavl-dev libev-dev \

-   apache2 apache2-dev libapache2-mod-wsgi-py3

-

-RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - && apt-get install -y nodejs

-

-# Install libssh from source (Version from apt is incompatible with libnetconf2)

-RUN git clone -b v0-7 http://git.libssh.org/projects/libssh.git ; cd libssh; mkdir build; cd build ;\

-    cmake ..; make; make install ; cd /

-

-# Install libyang

-RUN git clone -b devel https://github.com/CESNET/libyang.git && cd libyang; \

-  mkdir build; cd build && \

-  cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_JAVA_BINDINGS=OFF .. && make && make install && cd ../.. && ldconfig ; cd /

-

-# Install libnetconf2

-RUN git clone -b devel https://github.com/CESNET/libnetconf2.git && cd libnetconf2 && \

-  mkdir build && cd build && \

-  cmake -DENABLE_PYTHON=ON .. && make && make install && cd ../.. && ldconfig &&  \

-  python3 /libnetconf2/build/python/setup.py install && cd /

-# Manually running setup.py is a temporary workaround because of a bug in libnetconf2

-

-# Install sysrepo

-RUN git clone -b devel https://github.com/sysrepo/sysrepo.git ; \

-    cd sysrepo; mkdir build; cd build; \

-    cmake -DGEN_LANGUAGE_BINDINGS=OFF .. && make && make install; \

-    cd ../.. ; \

-    ldconfig ; cd /

-

-# Install netopeer

-RUN git clone -b devel https://github.com/CESNET/Netopeer2.git ;\

-    cd Netopeer2; mkdir build; cd build ;\

-    cmake .. && make && make install ; cd /

-

-# Prepare GUI 

-RUN git clone https://github.com/CESNET/liberouter-gui

-RUN cd /liberouter-gui/modules && git clone -b v2 https://github.com/CESNET/netopeer2gui 

-# && rm -rf /liberouter-gui/modules/example

-RUN cp /liberouter-gui/modules/netopeer2gui/app.config.json /liberouter-gui/modules/app.config.json && rm /liberouter-gui/modules/netopeer2gui/app.config.json

-RUN cd /liberouter-gui && python3 bootstrap.py && \

-    pip3 install -r backend/requirements.txt && \

-    cd frontend && npm install -g npm@7.5.2 && \

-    npm i -g @angular/cli && npm install --legacy-peer-deps

-

-# Temporary workaround until import is fixed for tools

-RUN rm /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss && \

-  cp /liberouter-gui/frontend/src/styles/_colors.scss /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss

-RUN echo "\$colorSuccess:     #44bd32;" >> /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss && \

-    echo "\$colorError:       #ee1d23;" >> /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss

-

-# Build GUI

-RUN mkdir /etc/httpd ; mkdir /etc/httpd/conf.modules.d 

-RUN pip3 install mod_wsgi

-RUN mod_wsgi-express module-config >/etc/httpd/conf.modules.d/00-wsgi.conf

-RUN pip3 uninstall mod_wsgi -y

-RUN cd /liberouter-gui/modules/netopeer2gui/frontend && npm i && npm run build:tools && cd

-RUN cd /liberouter-gui/frontend && npm run build && cp -R dist/* /var/www/html 

-

-# Setup apache server

-RUN mkdir -p /var/www/liberouter-gui && cp -r /liberouter-gui/backend /var/www/liberouter-gui

-RUN rm /var/www/liberouter-gui/backend/liberouterapi/modules/netconf && cp -r /liberouter-gui/modules/netopeer2gui/backend/. /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui

-RUN cp /liberouter-gui/modules/netopeer2gui/docker/wsgi.py /var/www/liberouter-gui/backend/wsgi.py

-COPY liberouter.conf /etc/apache2/sites-available

-RUN a2ensite liberouter && a2dissite 000-default

-RUN a2enmod rewrite

-COPY config.ini /var/www/liberouter-gui/backend/config.ini

-COPY .htaccess /var/www/html/.htaccess

-RUN chown -R www-data:www-data /var/www/liberouter-gui

-RUN chown -R www-data:www-data /liberouter-gui/modules/netopeer2gui/backend

-# App needs to write configuration files

-RUN chmod -R +w /var/www/liberouter-gui

-

-# Change root password for netconf connection

-# DO NOT USE IN PRODUCTION ENVIRONMENT!

-RUN echo 'root:docker' | chpasswd

-

-# Expose HTTP

-EXPOSE 80/tcp

-EXPOSE 830

-

-

-COPY services.sh /root

-CMD ["/bin/bash", "/root/services.sh"]

+FROM ubuntu:18.04
+
+# Install required binaries
+RUN apt-get upgrade && apt-get update -y && apt-get install -y \
+   mongodb python3 python3-dev python3-pip \
+   pkg-config \
+   git cmake clang curl \
+   libpcre3-dev swig \
+   zlib1g-dev libgcrypt-dev libssl-dev \
+   libprotobuf-c-dev protobuf-c-compiler libavl-dev libev-dev \
+   libffi-dev python3-setuptools nginx
+
+RUN curl -sL https://deb.nodesource.com/setup_15.x | bash - && apt-get install -y nodejs
+
+# Install libssh from source (Version from apt is incompatible with libnetconf2)
+RUN git clone -b stable-0.8 http://git.libssh.org/projects/libssh.git ; cd libssh; mkdir build; cd build ;\
+    cmake ..; make; make install ; cd /
+
+# Install libyang
+RUN git clone -b devel https://github.com/CESNET/libyang.git && cd libyang; \
+  mkdir build; cd build && \
+  cmake -DGEN_LANGUAGE_BINDINGS=ON -DGEN_JAVA_BINDINGS=OFF .. && make && make install && cd ../.. && ldconfig ; cd /
+
+# Install libnetconf2
+RUN git clone -b devel https://github.com/CESNET/libnetconf2.git && cd libnetconf2 && \
+  mkdir build && cd build && \
+  cmake -DENABLE_PYTHON=ON .. && make && make install && cd ../.. && ldconfig &&  \
+  python3 /libnetconf2/build/python/setup.py install && cd /
+# Manually running setup.py is a temporary workaround because of a bug in libnetconf2
+
+# Install sysrepo
+RUN git clone -b devel https://github.com/sysrepo/sysrepo.git ; \
+    cd sysrepo; mkdir build; cd build; \
+    cmake -DGEN_LANGUAGE_BINDINGS=OFF .. && make && make install; \
+    cd ../.. ; \
+    ldconfig ; cd /
+
+# Install netopeer
+RUN git clone -b devel https://github.com/CESNET/Netopeer2.git ;\
+    cd Netopeer2; mkdir build; cd build ;\
+    cmake .. && make && make install ; cd /
+
+# Prepare GUI 
+RUN git clone https://github.com/CESNET/liberouter-gui
+RUN cd /liberouter-gui/modules && git clone -b v2 https://github.com/CESNET/netopeer2gui 
+# && rm -rf /liberouter-gui/modules/example
+RUN cp /liberouter-gui/modules/netopeer2gui/app.config.json /liberouter-gui/modules/app.config.json && rm /liberouter-gui/modules/netopeer2gui/app.config.json
+RUN cd /liberouter-gui && python3 bootstrap.py && \
+    pip3 install -r backend/requirements.txt && \
+    cd frontend && npm install -g npm@7.5.2 && \
+    npm i -g @angular/cli && npm install --legacy-peer-deps
+
+# Temporary workaround until import is fixed for tools
+RUN rm /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss && \
+  cp /liberouter-gui/frontend/src/styles/_colors.scss /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss
+RUN echo "\$colorSuccess:     #44bd32;" >> /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss && \
+    echo "\$colorError:       #ee1d23;" >> /liberouter-gui/modules/netopeer2gui/frontend/projects/shared-styles/_colors.scss
+
+# Build GUI
+RUN cd /liberouter-gui/modules/netopeer2gui/frontend && npm i && npm run build:tools && cd
+RUN cd /liberouter-gui/frontend && npm run build && cp -R dist/* /var/www/html 
+
+# Setup ngix server with uwsgi
+RUN mkdir -p /var/www/liberouter-gui && cp -r /liberouter-gui/backend /var/www/liberouter-gui
+RUN rm /var/www/liberouter-gui/backend/liberouterapi/modules/netconf && cp -r /liberouter-gui/modules/netopeer2gui/backend/. /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui
+RUN cp /liberouter-gui/modules/netopeer2gui/docker/wsgi.py /var/www/liberouter-gui/backend/wsgi.py
+RUN pip3 install wheel && pip3 install uwsgi; mkdir /uwsgi; chown -R www-data:www-data /uwsgi
+
+COPY localhost /etc/nginx/sites-available/
+RUN ln /etc/nginx/sites-available/localhost /etc/nginx/sites-enabled
+
+COPY config.ini /var/www/liberouter-gui/backend/config.ini
+COPY .htaccess /var/www/html/.htaccess
+RUN chown -R www-data:www-data /var/www/liberouter-gui
+RUN chown -R www-data:www-data /liberouter-gui/modules/netopeer2gui/backend
+# App needs to write configuration files
+RUN chmod -R +w /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui/ ; mkdir -p /var/www/liberouter-gui/backend/liberouterapi/modules/netopeer2gui/userfiles
+RUN rm /etc/nginx/sites-enabled/default
+RUN pip3 install Flask-SocketIO==4.3.2
+
+# Change root password for netconf connection
+# DO NOT USE IN PRODUCTION ENVIRONMENT!
+RUN echo 'root:docker' | chpasswd
+
+# Expose HTTP
+EXPOSE 80/tcp
+EXPOSE 5555/tcp
+# EXPOSE 830
+
+COPY services.sh /root
+CMD ["/bin/bash", "/root/services.sh"]
diff --git a/docker/demo/config.ini b/docker/demo/config.ini
index 8c52a79..67c6486 100644
--- a/docker/demo/config.ini
+++ b/docker/demo/config.ini
@@ -1,9 +1,3 @@
-; THIS IS A DEFAULT CONFIGURATION
-; !!! DO NOT EDIT THIS FILE !!!
-;
-; If you want custom configuration you can copy this file and
-; pass it to Liberouter API as --config parameter
-
 [api]
 ; Enable debugging mode
 ; This sets logging to debug (most verbose) and enables Flask's debugging mode
diff --git a/docker/demo/liberouter.conf b/docker/demo/liberouter.conf
deleted file mode 100644
index cb8c907..0000000
--- a/docker/demo/liberouter.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-ErrorLog '/tmp/log.txt'

-LogLevel info

-

-<VirtualHost *:80>

-    DocumentRoot "/var/www/html/"

-    WSGIDaemonProcess libapi threads=5

-    WSGIScriptAlias "/libapi" "/var/www/liberouter-gui/backend/wsgi.py"

-    WSGIPassAuthorization on

-

-    <directory "/var/www/liberouter-gui/backend">

-        WSGIProcessGroup libapi

-        WSGIApplicationGroup %{GLOBAL}

-        WSGIScriptReloading On

-

-        Options All

-        AllowOverride All

-        Require all granted

-    </directory>

-    <directory "/var/www/html">

-        Options Indexes FollowSymLinks MultiViews

-        AllowOverride All

-        Require all granted

-    </directory>

-</VirtualHost>

diff --git a/docker/demo/localhost b/docker/demo/localhost
new file mode 100644
index 0000000..d27b53a
--- /dev/null
+++ b/docker/demo/localhost
@@ -0,0 +1,29 @@
+server {
+    listen 80;
+    listen [::]:80;
+
+    root /var/www/html;
+
+    location /socket.io {
+        include proxy_params;
+        proxy_http_version 1.1;
+        proxy_buffering off;
+        proxy_set_header Upgrade $http_upgrade;
+        proxy_set_header Connection "Upgrade";
+        proxy_pass http://127.0.0.1:5555/socket.io;
+    }
+
+    location /libapi {
+        include proxy_params;
+        proxy_pass http://127.0.0.1:5555/;
+    }
+
+    location ~* .(js|css|ttf|ttc|otf|eot|woff|woff2)$ {
+        add_header access-control-allow-origin "*";
+        expires max;
+    }
+
+    location / {
+        try_files $uri$args  $uri$args/ $uri $uri/ /index.html;
+    }
+}
diff --git a/docker/demo/netopeer2gui.ini b/docker/demo/netopeer2gui.ini
new file mode 100644
index 0000000..e12f60a
--- /dev/null
+++ b/docker/demo/netopeer2gui.ini
@@ -0,0 +1,13 @@
+[uwsgi]

+module = wsgi:app

+callable = application

+

+master = true

+processes = 5

+

+socket = netopeer2gui.sock

+

+chmod-socket = 660

+vacuum = true

+

+die-on-term = true
\ No newline at end of file
diff --git a/docker/demo/netopeer2gui.service b/docker/demo/netopeer2gui.service
new file mode 100644
index 0000000..840de94
--- /dev/null
+++ b/docker/demo/netopeer2gui.service
@@ -0,0 +1,17 @@
+[Unit]

+Description=uWSGI instance to serve netopeer2gui

+After=network.target

+

+[Service]

+ExecStart=/usr/local/bin/uwsgi --ini netopeer2gui.ini

+User=www-data

+Group=www-data

+RuntimeDirectory=/uwsgi

+Restart=always

+KillSignal=SIGQUIT

+Type=notify

+StandardError=syslog

+NotifyAccess=all

+

+[Install]

+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/docker/demo/services.sh b/docker/demo/services.sh
index 6fd0896..ed5e8cd 100644
--- a/docker/demo/services.sh
+++ b/docker/demo/services.sh
@@ -3,8 +3,10 @@
 mkdir -p /data/db 2>/dev/null
 mongod --fork --logpath /var/log/mongod.log
 
-service apache2 restart
+service nginx restart
 netopeer2-server
+#uwsgi --http 127.0.0.1:5555 --http-websockets --master --wsgi-file /var/www/liberouter-gui/backend/wsgi.py --callable application --processes 4 --threads 2 --stats 127.0.0.1:9191 > tmp/uwsgi.log
+python3 /var/www/liberouter-gui/backend
 
 # Keep the container running
 while [ 1 ]; do