Mixed content and WSS error after add taiga in my nginx reverse proxy

Hi,
I have a taiga service which worked normally but which was not secure in https. I added an nginx configuration to reverse-proxy this service:

server {
    listen 80;
    server_name my_alias_taiga.domain.local;
    rewrite ^(.*) https://my_alias_taiga.domain.local$1 permanent;
}

server {
        listen 443 ssl;
        server_name my_alias_taiga.domain.local;

        ssl_certificate /etc/letsencrypt/live/my_alias_taiga.domain.local/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/my_alias_taiga.domain.local/privkey.pem;
        include /etc/letsencrypt/options-ssl-nginx.conf;
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

        location / {
                proxy_pass http://mytaiga.domain.local:80;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header Host $host;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_buffering off;
                proxy_set_header X-Forwarded-Proto https;
                proxy_connect_timeout 90;
                proxy_send_timeout 90;
                proxy_read_timeout 90;

        }

        error_log  /var/log/nginx/mytaiga.domain.local-error.log warn;
        access_log  /var/log/nginx/mytaiga.domain.local-access.log  main;
}

After restarting nginx with systemctl restart nginx, then going to the web page https://my_alias_taiga.domain.local, the page displayed a blank page and when I opened the developer tool web page, there are these errors that came up:

Mixed Content: The page at 'https://my_alias_taiga.domain.local/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://my_alias_taiga.domain.local/events'. This request has been blocked; this endpoint must be available over WSS.
e.setupConnection @ app.js:3319

and

Uncaught (in promise) DOMException: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.
    at e.setupConnection (https://my_alias_taiga.domain.local/v-1631701833072/js/app.js:1:59357)
    at e.t [as setupConnection] (https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:116927)
    at e (https://my_alias_taiga.domain.local/v-1631701833072/js/app.js:1:16548)
    at Object.invoke (https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:232645)
    at https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:231497
    at mt (https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:208051)
    at Ve (https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:231475)
    at i (https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:216401)
    at Object.st [as bootstrap] (https://my_alias_taiga.domain.local/v-1631701833072/js/libs.js:1:216709)
    at https://my_alias_taiga.domain.local/v-1631701833072/js/app-loader.js:1:2348

I then first added these lines in the nginx configuration of my taiga service:

 location /ws/ {
            proxy_pass http://mytaiga.domain.local:80;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Proto https;

            proxy_connect_timeout 60s;
            proxy_send_timeout 60s;
            proxy_read_timeout 60s;
        }

nothing changed, I then modified a line present in taiga’s docker-compose.yml. Before it was like this:

TAIGA_WEBSOCKETS_URL: "ws://my_alias_taiga.domain.local"

I changed it to this :

TAIGA_WEBSOCKETS_URL: "wss://my_alias_taiga.domain.local"

Nothing changed

I don’t know what to do now, so i hope someone can help me to resolve this. Thank you for your attention.

Hi @tartrib

There is an example at the end of the Taiga 30min setup guide

First of all, you have to apply some changes in your .env file to use https and wss instead of http and ws:

TAIGA_SCHEME=https
TAIGA_DOMAIN=my_alias_taiga.domain.local
SUBPATH=""
WEBSOCKETS_SCHEME=wss

If you have directly modified the docker-compose.yml file you have to apply the necessary changes so that the different pieces use the secured external url (https://my_alias_taiga.domain.local and wss://my_alias_taiga.domain.local) for TAIGA_SITES_SCHEME and TAIGA_SITE_DOMAIN in x-environments and for TAIGA_URL and TAIGA_WEBSOCKETS_URL in the taiga-front service.

And now you have to configure your nginx with something like this.

server {
      listen 80;
      server_name my_alias_taiga.domain.local;
      rewrite ^(.*) https://my_alias_taiga.domain.local$1 permanent;
}

server {
      listen 443 ssl;
      server_name my_alias_taiga.domain.local;
      
      location / {
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Scheme $scheme;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_redirect off;
          proxy_pass http://localhost:9000/;
      }
      
      # Events
      location /events {
          proxy_pass http://localhost:9000/events;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $host;
          proxy_connect_timeout 7d;
          proxy_send_timeout 7d;
          proxy_read_timeout 7d;
      }
  
      # TLS: Configure your TLS following the best practices inside your company
      ssl_certificate /etc/letsencrypt/live/my_alias_taiga.domain.local/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/my_alias_taiga.domain.local/privkey.pem;
      include /etc/letsencrypt/options-ssl-nginx.conf;
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
      
      # Logs and other configurations
      error_log  /var/log/nginx/mytaiga.domain.local-error.log warn;
      access_log  /var/log/nginx/mytaiga.domain.local-access.log  main;
  }

I use http://localhost:9000/ because is the port using by the default setup. Use the port 80 for the taiga service (docker) and for the local nginx does not seem a good idea.

I hope this can help.

Best regards

Hi !

Thank you for your answer and sorry to react so late. I’ve change the docker-compose.yml with parameters like this :

taiga-front:
    image: taigaio/taiga-front:latest
    environment:
      TAIGA_URL: "https://my_alias_taiga.domain.local"
      TAIGA_WEBSOCKETS_URL: "wss://my_alias_taiga.domain.local"
      TAIGA_SUBPATH: "" # "" or "/subpath"
      PUBLIC_REGISTER_ENABLED: "true"

and also in the x-environment parameters :

TAIGA_SITES_SCHEME: "https"
TAIGA_SITES_DOMAIN: "my_alias_taiga.domain.local"

and nothing changed, when i look the devtools debug page, I have the same error as the first time. I wonder if this doesn’t come from the source code? because the error clearly tells me that it is a websocket problem and show me the app.js code.

Hi @tartrib

Have you changed your nginx configuration as I mentioned? Proxy passing to port 80 doesn’t seem to make much sense (by default, the taiga-gateway service use the port 9000). Follow the settings from the guide as much as possible.

Taiga could work perfectly without websockets. taiga-events and taiga-front, which use websockets, are only used to keep taksboards and kanban updated in real time (when you are looking at it and someone else modifies something). This functionality could be incorrectly configured and Taiga would continue to work without problems.

Regards

Hi @david.barragan

It’s true, I didn’t completely follow the recommendations. I’m still using port 80 because I told myself that it’s simply a port issue. I’m going to test by changing the port and then I’ll let you know the result.

Hi @david.barragan,

I changed the docker-compose.yml like this :

taiga-gateway:
    image: nginx:1.19-alpine
    ports:
      - "9000:80"
      #- "80:80"

It was what you suggested ? Because even after that, the error is persistent.

And have you change your nginx too? the proxy pass should be to localhost:9000

server {
      listen 443 ssl;
      server_name my_alias_taiga.domain.local;
      
      location / {
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Scheme $scheme;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_redirect off;
          proxy_pass http://localhost:9000/;    # <- HERE
      }
      
      # Events
      location /events {
          proxy_pass http://localhost:9000/events;     # <- HERE
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $host;
          proxy_connect_timeout 7d;
          proxy_send_timeout 7d;
          proxy_read_timeout 7d;
      }
  
      # TLS: Configure your TLS following the best practices inside your company
      ssl_certificate /etc/letsencrypt/live/my_alias_taiga.domain.local/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/my_alias_taiga.domain.local/privkey.pem;
      include /etc/letsencrypt/options-ssl-nginx.conf;
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
      
      # Logs and other configurations
      # ...
  }

Hi @david.barragan

Sorry but, if I change the proxy pass to localhost:9000, how the reverse proxy can redirect to the taiga server ?
you have probably been confused by all this information which lacks clarity so I will give you the context more clearly:

there is a server that runs taiga, this server is called

taiga-server.domain.local

to which I assigned an alias which is currently used in production

mytaiga.domain.local

I have another alias that I use to do my tests so as not to disrupt production

my_alias_taiga.domain.local but it’s not really an alias because in reality it’s an A record which points to the reverse proxy FQDN

I think that you thought the nginx server and the taiga server whas the same, but it’s two different server with different name and different IP. I hope I was able to provide more clarity.

So now i changed the nginx configuration with

location / {
                proxy_pass http://mytaiga.domain.local:9000;

but after restart the nginx server, i got a 502 bad gateway error.

Sorry but the two location blocks have to be exactly as I have indicated. You don’t have to change the word localhost with your domain. Nginx receives the request on port 443 (or 80) and redirects using the proxypass to localhost:9000, which is where taiga is listening.

So try again with

     location / {
          proxy_set_header Host $http_host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Scheme $scheme;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_redirect off;
          proxy_pass http://localhost:9000/;
      }
      
      # Events
      location /events {
          proxy_pass http://localhost:9000/events;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header Host $host;
          proxy_connect_timeout 7d;
          proxy_send_timeout 7d;
          proxy_read_timeout 7d;
      }

Hi @david.barragan,

Thank you for your explanation, I followed your instructions but it gave me a 502 Bad Gateway error.

Have you restarted/reloaded nginx for the changes to take effect?

If taiga is already running on localhost:9000, this should work. If it doesn’t work, there must be some error in the settings that we are not seeing.

  1. Check the settings.
  2. Make sure that http://localhost:9000 displays taiga perfectly.
  3. Start nginx and check if https://my_alias_taiga.domain.local works now.