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

Support for context path/ mounting #19

Closed
rosner opened this issue Aug 20, 2012 · 7 comments
Closed

Support for context path/ mounting #19

rosner opened this issue Aug 20, 2012 · 7 comments

Comments

@rosner
Copy link

rosner commented Aug 20, 2012

Hi folks,

right now I use one machine to deploy all my analytics stuff (sentry, countly). Usually I run those services so that they only listen on localhost. Then I use nginx to proxy the calls to the individual services. Sometimes there's also load balancing involved through nginx' upstream module.

Since I want to run all services as "subdirectories" it would be necessary that countly supports something like this:

var countly = express.createServer();
countly.use('/countly', app);
countly.listen(countlyConfig.web.port);

So my final setup would look something like this:

x.company.com/sentry
x.company.com/countly
x.company.com/countly/i
x.company.com/countly/o

What do you think of supporting this?

@osoner
Copy link
Member

osoner commented Aug 20, 2012

Hi Norman,

You can easily achieve that by changing the nginx configuration, just like;

server {
    listen   80;
    server_name  localhost;

    access_log  off;

    location = /countly/i {
        proxy_pass http://127.0.0.1:3001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location = /countly/o {
        proxy_pass http://127.0.0.1:3001;
    }

    location /countly/ {
        proxy_pass http://127.0.0.1:6001;
        proxy_set_header Host $http_host;
    }
}

Please tell me if I'm missing something.

@rosner
Copy link
Author

rosner commented Aug 20, 2012

Already tried that and it didn't work. My guess is that it'll work for the api app since there are no redirects nor static file requests. For example if I use

location /countly
...

and when I'm not logged in then countly redirects to /login and thus getting a 404.
I also tried to redirect rules but that doesn't work either.

An nginx based solution would be fine, but I guess that won't work.

@osoner
Copy link
Member

osoner commented Aug 20, 2012

Thats right, API will work fine but the frontend app will have issues since every redirection/post/get is hardcoded there. In order to support this client side javascripts + express/app.js needs to read a configuration value from somewhere.

I think we can add two configs;

  1. frontend/express/config.js: countlyConfig.web.path
  2. frontend/express/public/javascripts/countly/countly.config.js countlyCommon.SERVER_PATH

and perform every operation accordingly. Also countly.install.sh can ask a path from the user during installation and perform the changes in the files automatically.

@rosner
Copy link
Author

rosner commented Aug 20, 2012

What do you think about the static files? All static resources are referenced through absolute paths. So this config variable should be also accessable in template/html files.

As I'm new to express: I think that the mountPath option should be exposed to all views that reference assets. I'm trying to figure this out and hopefully provide a PR.

@osoner
Copy link
Member

osoner commented Aug 21, 2012

The first thing that I can think of is using a <base> tag inside the html files and remove leading / from each src/url etc. absolute path.

I'll keep you posted if I come up with anything else.

@ubershmekel
Copy link
Contributor

Another thing that needs to be done here is move all images under the css path because of http://stackoverflow.com/questions/2161377/is-the-html-base-tag-also-honored-by-scripting-and-css and here is the suggested solution http://stackoverflow.com/questions/3812375/specifying-base-url-for-css and I think I might have the pull request ready soon.

@ar2rsawseen
Copy link
Member

Implemented in b657d76
Same server config required as mentioned by @osoner
and also definition in countly config.js files in both api and frontend should define countlyConfig.path = "/countly"

ar2rsawseen pushed a commit that referenced this issue Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants