-
Notifications
You must be signed in to change notification settings - Fork 33
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
No 'Access-Control-Allow-Origin' header is present #14
Comments
Hey, https://enable-cors.org/server_meteor.html |
That's strange -- the language in the error specifically says that the CORS header is missing on the requested resource, which is the one hosting the Kadira package. All I've done on the Digital Ocean droplet was to mup setup && mup deploy this package with SSL. Furthermore, I've been able to use other docker packages on Github for Kadira without issue in the past from this subdomain. I'm eager to get yours up and running though because it seems to have solved some of the issues the others have (trimming mongodb/indexing/etc.). I'll keep digging and let you know what I come up with! |
You might be right, but I don't have any problems. |
Adding the following to the
Now I'm just trying to figure out why none of the incoming data is saving to mongodb... |
@jasongrishkoff Your solution helped with the CORS issue, but I'm seeing the same issue with data not saving mongodb. Where you able to figure that one out as well? Thanks in advance! 🙇 |
Did you configure a mongo replica set? |
Wow I can't believe I got a response so quickly on xmas :D. Happy holidays! I did set up a full replica set on mlab and verified that my user info went to the DB and double checked my appId/secret. I'm no longer getting the CORS issue, or any errors at all, but actual app data isn't flowing into the DB. Just like with @jasongrishkoff, I used MUP to deploy my kadira.mysite.com (running on AWS) while my main site www.mysite.com is on Galaxy. Any tips on where I can look into to keep troubleshooting? This repo has a lot of potential and I'd like to help out if I can at least get it up and running. |
:D Happy holidays! |
Sure, my mup.js is pretty simple.
I actually don't see any collection called RawSystemMetrics, here is what my freshly created replica set looks like: |
That is strange. Did you check server logs with |
I added the MONGO_OPLOG_URL, double checked that I opened up ports 11011 and 7007, but still no change. I'm still working it but not even sure where to look at this point, I'll probably start adding more logs statements to the kadira source and re-deploy to try to figure out. Any pointers would be very much appreciated :D. The logs were not very useful, nothing unexpected, I pasted them below.
|
I'm still troubleshooting, but I noticed that I think the quick fix above to add the CORS header to every response is masking whatever issue that is going on rather than fixing the underlying issue. |
@jehartzog I had noticed the same -- all responses to the /sync request were returning garbled HTML. It didn't seem right. And this was with MONGO_OPLOG_URL. Those were the exact same logs I was seeing on my side. |
Thanks @jasongrishkoff, I'm at a bit of a loss at where to look now. I've dumped the incoming requests to logs and verified that my kadira server is receiving at least the /sync requests from my main app and sending a response, but it looks like that response isn't correct. And I can't yet verify whether or not if my kadira app is getting any of the actual meteor app data network requests. The next step is to go through the code base and figure out where something unexpected is happening, but with this size of code base that's a bit of a task to figure out. If anybody has tips on where to start looking, that will be greatly appreciated :D. |
Do you have the same problems when you run the apm server on your dev machine? Which monitoring package are you using? I recommend https://github.com/lmachens/kadira |
I ran the entire setup (my app + APM server) locally on my dev machine, it returned the exact same behavior as above. I didn't get the CORS error since everything was on localhost, but the sync timestamp was still HTML gibberish and no app data flowed to the apm server. I tried using https://atmospherejs.com/lmachens/kadira but it crashed 20 seconds after starting up:
I then locally installed https://github.com/lmachens/kadira, but had the same error. |
So weired. I have more time next week and will take a deeper look at it. Maybe you can find out the problems. My setup is a mongodb 3.4 single replica set with a meteor 1.6 client. Servers OS is ubuntu. |
It's really weird. We run Kadira from this project for about 2 weeks in 2 different production environments with meteor 1.6.0.1 apps, and the only error we had was
and it was fixed with "const oplogConn = new MongoOplog" ---> "const oplogConn = MongoOplog" |
Thanks for the responses, I'm still working on it to isolate what is going on. Here is the setup I tried everything on: mLab shared replica set running 3.4.10 I also tried it locally and saw the exact same issues, so perhaps it's something with my app, although it seems I'm not the only one seeing this issue. I'll try reverting to some previous versions to see if that will fix it. |
Did you use mup locally, too? If yes, try without it. |
Nope, mup for the EC2 ubuntu production/staging deployment. After the tip to run locally, I ran the two meteor projects locally on different ports. Now that I think about it, I didn't set up a local replica set, I just used the default meteor create mongodb instance, so I may look into doing that. |
Yap, will not work without RS. Use official mongo:3.4 image with storage engine wiredtiger and replicaset name options. Then init one-member RS and APM runs perfect with it. |
Update: Local deployment works, I had misconfigured my settings.json file when I set my endpoint by not setting port 11011. That explains why my time sync was getting a html response @jasongrishkoff . Fixing my .json config by adding 11011 as the port as below helped.
Sorry for wasting your all time with this step that's listed in the documentation, my bad. It now works fully on development using the meteorhacks:kadira package (the lmachens:kadira still crashes 20 secs after launch). Turns out if the kadira client tries to auth on a webserver port 80, it doesn't throw an error message so it's not obvious what is going on. After adding the correct port now throws an expected error message I'll keep trying to set it up to work with MUP and pass on any big 'gotchas' if I find any. |
@jehartzog Makes sense -- I too tried 11011 but got the same |
Okay, up and running at last. Here are the takeaways, @lmachens let me know if you want me to put together a PR to add this to documentation for you. Here are the steps you need to take to use MUP to deploy this to a remote server: In your Meteor app, you must use set your endpoint to use
In your mup.js file for this Kadira project, a few things are important:
A few notes about what I've found so far:
|
Good to here that you found a solution. It is true, that it is not easy to set up the reverse proxy with mup for multiple ports. You need 1 port for the UI (3000) and 1 port for the engine (11011). Take a look at https://github.com/dbendelman/nginx-proxy which allows multiple ports. My mup.js:
The replica set is required for the alerts system. If you don't need it, it might work with a non-replica mongodb instance. Tell me what you think. We should update the README 👍 |
@lmachens Looks like your mup version allows https, right? |
I don't use the mup proxy settings, so https is not configured by mup. |
Alright I got everything up and running just fine over https completely with a single meteor app + local mongo replica set using MUP plus a couple dirty script hacks. I used the reverse proxy for MUP set up with two domains:
These are commands are needed to fix up the default MUP deployment and need to be re-preformed when the app is deployed/restarted :(. This is needed because this PR hasn't been released yet.
This one is needed due to lack of good Virtual Host support with the built in MUP proxy. It's ugly, and I'm not a great regex writer, but all it does is change the first upstream server (which on my build was apm-engine.mydomain.com) from 80 to 11011, sending all the traffic to the correct engine port.
|
@jehartzog There was a bug in https://github.com/lmachens/kadira. It should be fixed now in 2.30.6. |
So the bug I reported in your kadira fork preventing me from even running it locally, so I didn't even try it with MUP. I went ahead and tried 2.30.6 and it worked just fine. I fully expect it will work will with MUP too. I'm not ready to deploy it to my staging/production yet, but I will do so eventually and raise another issue at that repo if it doesn't work for any reason. It's funny when I was looking into what you did with the Kadira fork, it included pulling in the jquery removal PR which I had moved over to the meteor-apm-agent package. I really like the work you've done so far and I'll be using both your packages in my production app. Thanks for keeping them up to date and let me know if you need any assist! |
@jehartzog have followed your steps but authentication keeps failing on port 11011. Will keep digging into this, but wondering if I'm missing something here. I copy your mup.js, changing the domains and server info. Then I do mup config && mup deploy. Then I ssh into the server and execute:
Followed by: I can access the https domains for both kadira.domain.com and kadira-engine.domain.com, including as part of my Kadira config (it authenticates just fine). As soon as port 11011 enters the scene things go south :( The logs seem like everything's setting up fine as well, so I'm thinking this has something to do with mup-nginx-proxy:
|
The sed regex to edit nginx
You should see two
Change the last line to
The other domain, with an identical upstream config, will be for the other domain Overall I'm not happy with this setup, it's obviously hacked together and brittle, but it works for now :/. |
Wow, it's working! Exciting stuff! Thanks for the quick response and your help. I actually think your original sed worked because when I looked at the config it was port 11011 as you said. I think where I was going wrong was by trying to include port 11011 in my Meteor config when connecting to Kadira. |
@jehartzog @jasongrishkoff : Would it do any damage to whack the regex into a cron script on the docker host machine, to run e.g. every 5 minutes ? I mean this one:
It's still brittle and hacky, but at least it could survive restarts and it could also be automated in the sample setup as part of the post-setup hook. |
@cunneen that would probably break things as if you run the |
Thanks @jehartzog. That sounds like a better approach. |
For the benefit of anyone still looking for an automated workaround, I've had some success with adding the attached shell script and
#!/usr/bin/env bash
##################################################
# Workaround meteor-apm-server / nginx proxy bug
# https://github.com/lmachens/meteor-apm-server/issues/14
#
# To Install:
# 1. Put this file onto the docker host machine as /home/ubuntu/fix_nginx_proxy_port.sh
# 2. Add a crontab entry:
# crontab -e
# Add the following line (without leading spaces):
# */30 * * * * docker exec -i mup-nginx-proxy bash < /home/ubuntu/fix_nginx_proxy_port.sh > /home/ubuntu/fix_nginx_proxy_port.log
#################################################
TMPFILE=`tempfile`;
awk '
BEGIN{in_block=0;}
/upstream apm-engine/{
in_block=1;
print $0;
next;
}
/server (.*):80/{
if(in_block == 1) {
newval = $0;
gsub(/:80;$/,":11011;",newval);
print newval;
} else {
print $0;
}
next;
}
/[\}]/{
in_block=0;
print $0;
next;
}
{print $0;}
' /etc/nginx/conf.d/default.conf > ${TMPFILE} && \
mv -f ${TMPFILE} /etc/nginx/conf.d/default.conf && \
nginx -s reload
|
@cunneen Thanks a ton for posting this, my halfway solution would sometimes result in the fix dropping off, which would lead to no monitoring. I used your instructions and they worked like a charm, no modifications needed. |
Thanks for creating this!
I'm using mup to deploy this to a Digital Ocean droplet. My setup is as follows:
I keep encountering this issue: "Failed to load https://kadira.domain.com/simplentp/sync: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.domain.com' is therefore not allowed access."
I've tried jiggling with the settings in
server/config/security.js
-- am I on the right path?The text was updated successfully, but these errors were encountered: