asciimoo / morty

Privacy aware web content sanitizer proxy as a service
GNU Affero General Public License v3.0
485 stars 58 forks source link

Error: invalid "mortyhash" parameter #112

Open gkkulik opened 2 years ago

gkkulik commented 2 years ago

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?

harryssecret commented 2 years ago

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.

Zepmann commented 2 years ago

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.