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

pcopy behind nginx proxyserver #81

Open
elearningdienst opened this issue Nov 22, 2021 · 3 comments
Open

pcopy behind nginx proxyserver #81

elearningdienst opened this issue Nov 22, 2021 · 3 comments

Comments

@elearningdienst
Copy link

elearningdienst commented Nov 22, 2021

Hi folks, looks like pcopy is a good self-hosted service for my needs. Is there a way to run it behind a nginx reverse proxy? Tried a basic conig, but it always says "bad gateway"

In my config file the server and port is set as followed
'''
ServerAddr pcopy.XXXX.de:443
ListenAddr :443/https
'''

On the nginx (another machine) I have a ssl certificate from letsencrypt.

XXX@pcopy:~$ pcopy join pcopy.XXXX.de:443 work
Joining clipboard at pcopy.XXXXX.de:443 ... failed.
Cannot connect to https://pcopy.XXXXX.de:443: Get "https://pcopy.XXXXX.de:443/info": dial tcp 127.0.1.1:443: connect: connection refused

Sometimes (don't know why) it asked me for a password. But the hashed password from the configfile does not work.

Any Ideas?

@binwiederhier
Copy link
Owner

It should be possible. I don't see why not. I'll give it a shot tonight

@binwiederhier
Copy link
Owner

binwiederhier commented Nov 23, 2021

Oh my. I can reproduce it locally. I must have screwed something up in the latest release. I'll fix tonight.

@binwiederhier
Copy link
Owner

binwiederhier commented Nov 23, 2021

Scratch that. It's just a little trickier.

In this example, port 12345 is the external port and 2580 is the internal port. If you want to use SSL, you should terminate HTTPS/SSL in nginx on 12345 and forward HTTP (not HTTPS!) to pcopy.

That's why pcopy is listening on HTTP (ListenAddr :2580/http), but advertising the external ServerAddr http://your-external-domain.mydomain.com:12345:

$ cat ~/.config/pcopy/server.conf 
ServerAddr http://your-external-domain.mydomain.com:12345
ListenAddr 127.0.0.1:2580/http
$ cat /etc/nginx/sites-enabled/pcopy 
upstream pcopy_upstream {
  server 127.0.0.1:2580;
}

server {
  listen 12345;
  server_name pcopy;

  location / {
    proxy_pass         http://pcopy_upstream;
    proxy_http_version 1.1;
    proxy_set_header   Host $http_host;
    proxy_connect_timeout   1m;
    proxy_send_timeout      1m;
    proxy_read_timeout      1m;
  }
}

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

2 participants