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

using reverse proxy #1

Open
ploef opened this issue Jun 27, 2016 · 5 comments
Open

using reverse proxy #1

ploef opened this issue Jun 27, 2016 · 5 comments

Comments

@ploef
Copy link

ploef commented Jun 27, 2016

Hi,

Did you try to get this container running behind an reverse proxy (apache or nginx). I just can't get this to work (keep getting 404's).

I found this on the tailon website but it is not working. Perhaps it is because it;s running inside docker container?

location /tailon/ws {
proxy_pass http://localhost:8888/tailon/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location /tailon {
  proxy_pass http://localhost:8888;
}

Regards,
Peter

@sago007
Copy link
Owner

sago007 commented Jun 28, 2016

It appears to work like this:
default.conf

server {
    listen       8084;
    server_name  sago_proxy;

location / {
  proxy_pass      http://localhost:8080;
  proxy_redirect  http://localhost:8080/ /;
  proxy_read_timeout 60s;

  # May not need or want to set Host. Should default to the above hostname.
  proxy_set_header          Host            $host;
  proxy_set_header          X-Real-IP       $remote_addr;
  proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
}

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Running tailon:
docker run -it -v /var/log:/data --user=1000 -p 8080:8080 sago007/docker_tailon

Running nginx:
docker run -it --rm -v /ABSOLUTE/PATH/TO/FOLDER/WITH/DEFAULT.CONF:/etc/nginx/conf.d --net host -t nginx:1.10

Can be accessed with http://localhost:8084/

If you want a subfolder you need a rewrite rule.
This default.conf:
default.conf

server {
    listen       8084;
    server_name  sago_proxy;

location /tailon/ {
  rewrite ^/tailon(/.*)$ $1 break;
  proxy_pass      http://localhost:8080;
  proxy_redirect  http://localhost:8080/ /;
  proxy_read_timeout 60s;

  # May not need or want to set Host. Should default to the above hostname.
  proxy_set_header          Host            $host;
  proxy_set_header          X-Real-IP       $remote_addr;
  proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
}

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

Means that http://localhost:8084/tailon/ works.

@sago007
Copy link
Owner

sago007 commented Jun 28, 2016

In your case you properly need a rule like:
rewrite ^/tailon/ws(/.*)$ $1 break;

@ploef
Copy link
Author

ploef commented Jun 28, 2016

Thanks! I'm going to give it a try and will let you know how it worked out.

@ploef
Copy link
Author

ploef commented Jun 28, 2016

This is almost working. I tries both rewrite rules. The first one doesn't work with the second one I only
got one 404 left:

GET http://sago_proxy/logs/ws/info?t=1467136255761 404 (Not Found)

server {

listen 80;
server_name sago_proxy;

location /logs/ {
  #rewrite ^/logs(/.*)$ $1 break;
  rewrite ^/logs/ws(/.*)$ $1 break;
  proxy_pass      http://localhost:8888;
  proxy_redirect  http://localhost:8888/ /;
  proxy_read_timeout 60s;

# May not need or want to set Host. Should default to the above hostname.
  proxy_set_header          Host            $host;
  proxy_set_header          X-Real-IP       $remote_addr;
  proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
}

}

@sago007
Copy link
Owner

sago007 commented Jul 8, 2016

It should be noticed that you can also start with a different mount dir like this:
docker run -it -v /var/log:/data --user=1000 -p 8080:8080 sago007/docker_tailon /tailon/run.sh -r '/tailon/'
That way you can add the same arguments as in the example and you can avoid the rewrite rules.

I would not normally recommend this road as I believe the proxy should hide these details but it is an option.

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