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

cannot fallback to web server #235

Open
pacmac opened this issue Mar 25, 2017 · 2 comments
Open

cannot fallback to web server #235

pacmac opened this issue Mar 25, 2017 · 2 comments
Labels

Comments

@pacmac
Copy link

pacmac commented Mar 25, 2017

I have tried this several times since I have been using sniproxy and just tried it again but cannot get it tro work.

I need to be able to run a NGINX server hosting web pages as well as sniproxy on the same server.

I understand the way to do this is to use fallback, so I have configured nginx to listen on 8080 and need sniproxy to fallback to 8080 so that requests coming in for a local web page are displayed, right now that is not happening.

Here's the config setting for sniproxy:

listener 0.0.0.0:80 {  
  table http
  proto http
  fallback 127.0.0.1:8080
  access_log {
    filename /var/log/sniproxy/http_access.log
    priority notice
  }
}

and here's the config for NGINX:

server {
  listen 0.0.0.0:8080;
  ... etc etc

I can connect to the webserver directly on 8080 but of course that's no good as it needs to be accessed via 80

The connection just hangs and eventually times out with 'Backend not Available'

what am I doing wrong and / or can this be done ??

@pacmac
Copy link
Author

pacmac commented Mar 25, 2017

OK, I think I just figured it out, not sure if this is the correct way but it appears to work, in my table, before the wildcard redirect I add entries for local domain names to be served.

table "http" {
  some-domain.com 123.4.56.789:8080
  .*\\.* * 80
}

But I have a feeling that this may end up with recursion ??

@dlundquist
Copy link
Owner

dlundquist commented Mar 25, 2017

I use a UNIX socket for connection to the fallback nginx server. It looked like in your first post, you had Nginx listening on a specific IP which was not the loopback address so that could have been an issue.

sniproxy.conf:

listen 80 {
        proto http
        table vhosts
        fallback unix:/var/run/nginx-http.socket  
}
  
listen 443 {
        proto tls  
        table vhosts
        fallback unix:/var/run/nginx-https.socket
}

nginx.conf:

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 256;
}

http {
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        server {
                listen unix:/var/run/nginx-http.socket;
                server_name socket.localhost;

                location / {
                        root /srv/www;
                        index index.html index.htm;
                }
        }

        server {
                listen unix:/var/run/nginx-https.socket ssl;
                server_name socket.localhost;
                ssl_certificate /etc/nginx/wildcard.pem;
                ssl_certificate_key /etc/nginx/wildcard.pem;

                location / {
                        root /srv/www;
                        index index.html index.htm;
                }
        }
}

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

No branches or pull requests

2 participants