Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-hosting atuin with apache as reverse proxy #1099

Closed
Flowdalic opened this issue Jul 12, 2023 · 5 comments
Closed

Self-hosting atuin with apache as reverse proxy #1099

Flowdalic opened this issue Jul 12, 2023 · 5 comments

Comments

@Flowdalic
Copy link

Flowdalic commented Jul 12, 2023

This issue has two concerns: 1. It is about self-hosting autin with apache as reverse proxy 2. it is about "Error: error decoding response body: expected value at line 1 column 1" when trying to login

I am not sure if 2. is caused by me misconfiguring 1., but in any case, the error message in 2. could maybe improved. In fact I am stuck with 1. and miss general tooling, command line switches and techniques to diagnose the root cause. Of course, please do not rule out that I am just incompetent.

So here is what I did

  1. Atuin server, configured to listen on localhost:8888. The server seems to be running fine and has access to postgres
  2. Apache virtual host, with
ProxyPass "/atuin" "http://localhost:8888/"
ProxyPassReverse "/atuin" "http://localhost:8888/"

in its config. And, in fact, accessing https://mydomain.org/atuin, returns

{"homage":"\"Through the fathomless deeps of space swims the star turtle Great A'Tuin, bearing on its back the four giant elephants who carry on their shoulders the mass of the Discworld.\" -- Sir Terry Pratchett","version":"15.0.0"}

But I am not sure if this is supposed to happen. I only suspect that this is the atuin server talking because the version number. I am also not sure if I should set path = "/autin" in atuin's server.toml.

And upon login, I get

$ atuin login                                                                                                                                                                                                                                           
Please enter username: flow
Please enter encryption key [blank to use existing key file]:    
Please enter password: 
Error: error decoding response body: expected value at line 1 column 1

Caused by:
    expected value at line 1 column 1

Location:
    /data-scratch/var-tmp/portage/app-shells/atuin-15.0.0/work/atuin-15.0.0/atuin-client/src/api_client.rs:83:21

I would appreciate any help setting up my atuin server. Thanks in advance. :)

@Flowdalic
Copy link
Author

Same behavior with atuin 16.0. Any help would be appreciated.

@forquare
Copy link

forquare commented Nov 7, 2023

It's been a long while since I used Apache, but I got this working using nginx today with the following configuration:

server {
	listen 443 ssl;

	ssl_certificate /usr/local/etc/ssl/domain/fullchain.pem;
	ssl_certificate_key /usr/local/etc/ssl/domain/privkey.pem;

	server_name atuin.domain.co.uk;

	location / {
		proxy_pass http://172.16.0.5:8888/;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}

	access_log /usr/local/var/log/nginx/atuin.domain.co.uk.log;
	error_log /usr/local/var/log/nginx/atuin.domain.co.uk.error.log;
}

I don't think it's important, but background to my setup: I run FreeBSD where nginx runs in a jail, and other services run in other jails on a network only accessible internally to the box.

I use the PF packet filter to pass HTTP(S) traffic to the web jail which then proxies to the various other services - atuin runs in a jail with the IP address 172.16.0.5, which you can see in the example above. I suspect the above would also work to proxy to localhost also.

I had tried to pass specific paths, but had similar results to yourself (including nginx returning HTTP 405 on a number of calls).

Right now, if I visit https://atuin.domain.co.uk I get:

{"homage":"\"Through the fathomless deeps of space swims the star turtle Great A'Tuin, bearing on its back the four giant elephants who carry on their shoulders the mass of the Discworld.\" -- Sir Terry Pratchett","version":"17.0.1","total_history":36203}

And if I visit any specific path (e.g. /atuin) I get a HTTP 418:

🫖

But my atuin client is connecting, registering, and sync'ing just fine with my above configuration.

Hopefully this is helpful to someone.

@RogerSik
Copy link

I have the same issue with 17.1.0 and Traefik (in Kubernetes). Using own subdomain for it.

@RogerSik
Copy link

RogerSik commented Dec 30, 2023

I go it fixed.

Instead of

## address of the sync server
sync_address = "https://atuin.example.org/"

i wrote

## address of the sync server
sync_address = "https://atuin.example.org"

(File: ~/.config/atuin/config.toml)

(see missing slash) and it works now fine. :)

@Flowdalic
Copy link
Author

Turns out my configuration had an, at least sylistically, similar issue. The first argument of the ProxyPass* directive from the Apache configuration needs a terminating slash (/).

ProxyPass "/atuin/" "http://localhost:8888/"
ProxyPassReverse "/atuin/" "http://localhost:8888/"

it seems to work now. Note that I did not set the path option in atuin's server configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants