morty icon indicating copy to clipboard operation
morty copied to clipboard

Error: invalid "mortyhash" parameter

Open gkkulik opened this issue 2 years ago • 2 comments

Hi, sorry to bother you but I can't figure this out. I installed Morty but I get empty images results when searching. When try to open image placeholders, Morty show up with the information:

Error: invalid "mortyhash" parameter

Could you point me in the right direction to sort this?

gkkulik avatar May 08 '22 21:05 gkkulik

Bump, I have the same problem. I have no error when i run everything, and i think my config file is correct. My instance is SearxNG one but i don't think it's a problem.

harryssecret avatar May 23 '22 13:05 harryssecret

Not affiliated with this project, but recently performed an installation (SearXNG with Morty).

For security, Morty and SearXNG share a secret key to process HMAC hashes, which SearXNG appends to Morty request URLs for the user's browser to follow and for Morty to verify. This prevents abuse of Morty as a full free proxy, since only URLs generated by SearXNG can be proxied.

Of course, the shared secret key must be the same for Morty and SearXNG. I do not know how you start either, so cannot give exact examples on how to configure this. The gist of it is:

  1. Generate a key: openssl rand -base64 33

  2. Append the key to Morty's startup parameters. An example: /usr/bin/morty -listen 127.0.0.1:3000 -key $KEY. Note that this is a bad practice, since the parameters will likely be logged (e.g. by systemd), and therefore the key as well. It is fine in most situations where Morty and SearXNG run on a system dedicated to them.

  3. Add the key to SearXNG's settings.yml:

result_proxy:
    url : $URL # Enter the URL to Morty here from the perspective of the user's browser, not from the perspective of the server)
    key : !!binary "$KEY" # Only enter the key here. Do not replace anything else.

Restart both Morty and the process under which SearXNG runs (e.g. uWSGI), and the proxy should work without issue from SearXNG.

Zepmann avatar May 27 '22 07:05 Zepmann