calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.47k stars 232 forks source link

Help with nginx and port 8080 #378

Closed goregrish closed 10 years ago

goregrish commented 10 years ago

H all,

I'm running this through niginx with the following config

server {
listen 80;

server_name movies.domain.com www.movies.domain.com;
error_log /var/log/nginx/sync.log;
root /media/storage/sync;

location / {
    proxy_pass http://localhost:8080;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
}

I seem to have to working now but I get the error about firewalls.

Uh oh!
It appears the connection to has failed. If this error persists, a firewall or antivirus is likely blocking     the connection, or the server is down.

Any suggestions where I should be looking? Can't figure out if it's a port error or a setting I missed.

goregrish commented 10 years ago

This does the trick.

   server {
   listen 80;
   server_name movies.domain.com www.movies.domain.com;
   error_log /var/log/nginx/sync.log;
   root /media/storage/sync;

   location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

The config...

# url for a websocket listener.
listen:
# Default HTTP server - default interface, port 8080
- ip: ''
port: 8080
http: true
https: false
full-address: 'http://movies.domain.com:80'
# Default Socket.IO server - default interface, port 1337
- ip: ''
port: 1337
io: true
# HTTP server details
http:
default-port: 80
domain: 'http://movies.domain.com'

# Specifies the root domain for cookies.  If you have multiple domains
root-domain: 'movies.domain.com'

# Specify alternate domains/hosts that are allowed to set the login cookie
# Leave out the http://
alt-domains:
- '127.0.0.1'
# Socket.IO server details
io:
domain: 'http://movies.domain.com'
default-port: 1337
calzoneman commented 10 years ago

I'm a little confused about what you're trying to accomplish here.

From your CyTube config, it looks like you still have Socket.IO running on port 1337, but then in your nginx config you have the websocket proxy tunnel configuration as if you were trying to proxy websockets on port 8080.

I'm glad that you got it working, but I'm not sure that your connection upgrades are actually doing anything. Check http://movies.domain.com/sioconfig for what URLs are actually being used for websocket connections.

calzoneman commented 10 years ago

Also, you can safely remove the :80 from your full-address in http. Every browser will assume port 80 if it is not explicitly specified.

EDIT: Wait, full-address is supposed to go in the http block, not one of the listeners. If you want to hop on IRC and send me your full config sometime (passwords removed), I can take a look for any potential problems.

goregrish commented 10 years ago

Yeah I had it balls up, this has done the trick.

upstream gtube {
server 127.0.0.1:8080;
}
 server {
 server_name movies.domain.com;
 listen 80;
 error_log /var/log/sync.log;
 root /path/sync;

 location / {
 proxy_set_header Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://127.0.0.1:8080;
 proxy_set_header Authorization "";
 }
}