The Great Open Source Debate with Elastic, Gluu and GitHub 🎤 Oct 27

Images links are not correct , using nginx reverse proxy

Description

Hi,

The link to the uploaded images only works in de app but not in the browser.
I have a nginx reverse proxy. Which location I have to add to make it work again in the nginx config?
Version 3.16.4

Server Setup Information

  • Version of Rocket.Chat Server: 3.16.4

  • Operating System: Ubuntu

  • Deployment Method:

  • Proxy: <!-- nginx/=

Hi.

You are going to have to provide us with a lot more information.

Nginx conf, logs, screenshots etc.

Read this for some ideas:

nginx config:

upstream rocket_backend {
  server 127.0.0.1:3000;
}

server {
    listen 443 ssl;
    server_name xxxxxx;
    access_log /var/log/nginx/rocketchat-access.log;
    error_log /var/log/nginx/rocketchat-error.log;
    ssl_certificate /etc/ssl/certs/ssl-bundle.crt;
    ssl_certificate_key /etc/ssl/private/xxxxxxx.key;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://rocket_backend/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forward-Proto http;
        proxy_set_header X-Nginx-Proxy true;

        proxy_redirect off;
   }
}

Screenshot 2021-08-13 at 12.09.23

The most common reason behind the class of your issue is incorrect Site_Url setting. Can you please check if you have it correctly set up or not?

Check - Administration > General > Site URL - make sure the value is the exact string you use in your address bar to naviagate to your rc instance. The template is - [protocol]://[domain_or_ip][:optional port][/optional subpath]

1 Like

Thx! That was the trick!

1 Like

Where I can edit this url? It is pointing to localhost now?

I don’t know. What was the previous site url?

You’re going to need to update the database directly. How to connect to the daemon, the name of the database - depends on the deployment method.

An example query would look like the following -

db.rocketchat_uploads.find({}).forEach(function(cursor) {
    cursor.url = cursor.url.replace(`^${ RegExp([OLD_SITE_URL]) }\/`, "[NEW_SITE_URL]/");
    db.rocketchat_uploads.save(cursor);
})

Granted that I’m not the best (or experienced) at writing MQL queries, without knowing the version of your mongo server, I can’t recommend anything less generic any way. For example you could use updateMany, but that’s only available starting version 4.2

Finally, before you attempt to use it, PLEASE PLEASE PLEASE back up your existing data FIRST.

If you need more help, surely let me know :slight_smile:

1 Like