ptpb / pb

pb is a formerly-lightweight pastebin and url shortener
Other
549 stars 52 forks source link

Change the returned URL? #164

Closed tmplt closed 8 years ago

tmplt commented 8 years ago

I have deployed pb on my own server, and I'm using nginx as a reverse proxy. Currently, on the page itself, and when I

echo test | curl -F c=@- "https://paste.hostname.tld"

the paste is created, but the url is http://[::]:8080/f5-D instead of https://paste.hostname.tld/f5-D. Where can I change this?

I assumed changing VARNISH_BASE in /etc/xdg/pb/config.yaml would be it, but nothing changed after I restarted pb.

I am using the AUR package, pb-git.

buhman commented 8 years ago

Where can I change this?

pb calculates this from incoming request headers. You can also use flask-specific config options, but I don't suggest doing this.

using nginx as a reverse proxy

So nginx is the thing connecting to pb/uwsgi here?

You should add:

proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;

To whatever block your proxy_pass directive is in.

The X-Forwarded-Proto stuff is from pb.util.absolute_url and the Host logic is somewhere several levels deep in that call stack. In theory, the host header should be X-Forwarded-Host, but that's more a flask/werkzeug bug than a pb problem I'd have to monkey with the app-level url_adapter to make that work, which is how _scheme works internally. Flask is completely shit. Blame @silverp1 for that design choice :smile:

VARNISH_BASE

Is used for cache invalidation; you should probably remove that from your config if you don't have a validly configured varnish server there.

tmplt commented 8 years ago

My nginx.conf now contains:

location / {
    proxy_pass http://[::]:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto https;
}

and it works. Cheers!

buhman commented 8 years ago

and it works

Crazy how code does that.