Flask Webserver using nginx

  • I have an alternativ UniPi control panel runing using Flask webserver. For the four 1w temp sensors I include graphical gauges. It works perfectly with long polling. Now i would like to use websockets (better performance) and nginx, which is also used with evok.
    In the Flask documentation I found the following guidelines:

    Using nginx as a WebSocket Reverse Proxy
    It is possible to use nginx as a front-end reverse proxy that passes requests to the application. However, only releases of nginx 1.4 and newer support proxying of the WebSocket protocol. Below is a basic nginx configuration that proxies HTTP and WebSocket requests:

    server {
        listen 80;
        server_name _;
        location / {
            include proxy_params;
        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";

    In etc/nginx/sites-enabled I found a evok File. Can I use this file for my configuration? evok and my app would both come in on port 80?

    I also followed these guidelines:
    up to point 10 all worked ok, but with nginx configuration I don't know how to coexist with evok.

    As I am not a Raspian/Debian/Unix specialist, any help is very welcome.

  • Evok uses the same method to run both the API and the server on the same port. You can indeed use it by modifying the /etc/nginx/sites-enabled/evok file.

    That said, MAKE SURE TO BACK UP YOUR CARD FIRST! Messing with the configuration file can be somewhat error prone.

  • Hi Tomas,

    if I listen to port 80 and use location /fl (like /ws for evok), how can I then call this location from my chrome browser?

  • @juntiedt

    If you set it up correctly you can put IP_ADDRESS/fl into your browser to visit the website.

  • Hi Tomas,

    I changed evok File in sites-enabled and called "sudo service nginx restart" or "sudo service nginx reload" but nginx seems to not recognize the changes in evok File. Even rebooting did not load the new configuration. What am I doing wrong? :-(

  • @juntiedt

    You must have made your changes wrong I'm afraid. Try "sudo systemctl status nginx". NGINX configuration is documented in detail on the NGINX project website, where you can find more help on how to create your desired configuration. Evok doesn't use any non-standard option that I am aware of.

Log in to reply