-
Notifications
You must be signed in to change notification settings - Fork 412
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
Iron-router behind nginx proxy #154
Comments
I'm a little confused here. Are you trying to prefix all routes with /scheduler? |
Well kind of. In the end I'm trying to serve multiple meteor apps on one domain, each with different path (server.example.com/scheduler, server.example.com/app2 and so on). This is handled by the nginx proxy. Obviously I shouldn't need to add that prefix to ironrouter's routes, as the ROOT_URL variable for each meteor instance includes that prefix. But now ironrouter can't find any routes. After that my second attempt was to hack my app by including the prefix to routes in my app. When I did that, ironrouter correctly serves all the pages, but after that I can't use Router.path('name'), as it returns URL's that contain the prefix twice. It seems to me that ironrouter does not handle the ROOT_URL correctly if it contains a path in addition to domain name. Or then my configuration just has some bug which I can't find. |
Are you sure your nginx config is correct? If your
I think it would strip |
@mr-kimia, The Router uses the entire path on the client. So whatever is in the browser pathname. This all happens on the client. A possible improvement would be to make the ROOT_URL what we use instead of what's in the browser. Is that what you're suggesting? I closed the issue, but we can continue discussion and possibly create a design issue. |
@cmather it looks like making all routes relative to ROOT_URL by default would be the way to go. In a lot of cases it makes sense to run an entire meteor app within a unique route of a domain. For example: On development, I'd use something like http://192.168.1.1:3000/ but when deployed I'd use http://myapps.com/app1 Or if I'm releasing this app as an open source project, some people might want to run it in an entire domain or limit it to a route. |
@thatjuan, That's an interesting approach. |
@cmather I'm temporarily reading from Meteor.absoluteUrl() and then taking the route portion of it to append it to all of my route declarations. |
@thatjuan |
I figured out the problem. I have some programmatic url references to the image and font files, which also I need to append with the app name. Too many changes to the code just to support this. |
I have the same problem when my app is in subfolder. |
@eprabhakar how did you solve the problem with the image and font files in your case? |
@meule,
Then, in the client router
Then, I will have a helper called 'logourl' in one of the top level client helper files (it will be invoked first and available).
Finally, in the template, it will be something like
If there is an appname in the ROOT_URL, the logourl helper will return the appname subfolder path and it will actually use the 'public' folder inside the app subfolder.. Hope the above is clear and helpful to you. |
@eprabhakar, thank you so much! |
@meule
|
+1 for Iron Router to support ROOT_URL |
This has just bitten me when trying to run the example todos app behind nginx and under a test URL (i.e. non-'/' location). Would be good if ROOT_URL could be supported. (pathFor caused the most obvious problem for me - links end up removing the initial path component) |
+1 here too. We need to run multiple meteor apps within a single nginx instance, proxied from different subdomains (e.g. http://myhost/app1 and http://myhost/app2). It would be nice if we didn't have to rewrite the app to support being run in a subdomain. |
+1. We have a simple meteor app with no routes and it works fine with a ROOT_URL of http://example.com/one. A more complex app is mounted at http://example.com/two. The routes.js of path: '/' will fail because the ROOT_URL_PATH_PREFIX is not being removed and there is no route (nor should there be) for '/two/' |
+1. Would also like to run two meteor applications within the same single nginx instance. |
I've slightly modified the
I created a pull-request for this so you can have a look... |
It seems that iron router doesn't handle meteor environment variable ROOT_URL properly.
For example i have defined route:
which works when running local debug server. In production environment I have to run meteor behind nginx reverse proxy, which has configuration like this:
now I run the meteor server:
ROOT_URL="http://server.example.com/scheduler" PORT=3000 node main.js
When i try to connect to http://server.example.com/scheduler I get this error to browser js console: "Error: No route found for path: /scheduler/".
Ok, so I figure out that I just modify the urls in router to something like this:
Now the index page at http://server.example.com/scheduler works but all the links produced by router contains additional scheduler part like this: http://server.example.com/scheduler/scheduler/reserve
Am I doing something wrong, or is this a bug in iron router?
The text was updated successfully, but these errors were encountered: