gramps-project / gramps-web-api

A RESTful web API for Gramps - backend of Gramps Web
https://www.grampsweb.org
GNU Affero General Public License v3.0
82 stars 45 forks source link

GUI works via localhost but not through proxy #300

Closed greenship24 closed 2 years ago

greenship24 commented 2 years ago

I'm unsure if this belongs here or in the JS project (I believe here) but my issue is this-

I stood up a quick setup in kubernetes. The flow is to ingress-nginx --> gramps-service --> gramps--pod using the v0.12.0 image.

If I do a kubectl port-forward $grampspod 8080:5000 I can access the GUI just fine at localhost:8080. All images and data load. Pod logs show no issues really (does show Unable to init server: Could not connect: Connection refused but that seems somewhat normal according to Issue 183.)

Now if I try to access it via the ingress at a FQDN, the overall GUI loads (which should be the JS portion) but none of the data shows save a map (which might be cached.) I cannot see a list of people, I cannot see any kind of info on Lists, Family Tree, Blog, etc. etc.

When I access it this way, I get presented with a Unable to init server: Could not connect: Connection refused on every click of the webpage.

Is there something about how this is set up that is causing this or just a limitation of the image? I have set CORS_ORIGINS to "*" but it seems more like maybe it just is only set to listen on localhost and not all interfaces. So maybe this is why it works via a port-forward direct to the pod but cannot access it via a service/ingress? Edit- Can see via the Dockerfile that it's set to listen on 0.0.0.0 so shouldn't be that.

Would love to provide more logs if possible but I don't see much.

Specs:

DavidMStraub commented 2 years ago

Hi, I suggest to use curl or httpie to query the API directly, to see if you can reach it or not.

greenship24 commented 2 years ago

It appears I can query the API just fine through port-forward or going through the ingress.

Let me add some ingress annotations and I'll update. I would guess something is being dropped at that point.

DavidMStraub commented 2 years ago

Great! Next step is to look at the Browser Console, especially the Network tab, when looking at the frontend. What errors does it show?

greenship24 commented 2 years ago

Ahh- forgot I had looked at that earlier. Here's the usual after loading it and clicking around a few times.

[CanvasBlocker] invalid content script order: require not defined at https://familytree.example.com/ f91d7dc4-839d-4fce-b59a-eb7d1c716a85:17:16
ServiceWorker registered. familytree.example.com:1:140
The resource at “https://familytree.example.com/83e2ff6a.js” preloaded with link preload was not used within a few seconds. Make sure all attributes of the preload tag are set correctly. familytree.example.com
Error: Promised response from onMessage listener went out of scope

All JS blockers turned off. I've used a few browsers and OSs (Linux, windows).

83e2ff6a.js:322 GET https://familytree.example.com/api/translations/en?strings=[%22_Media%20Type:%22,%22_Names%22,%22_Save%22,%22Abbreviation%22,%22Abort%20changes?%22,%22About%22,%22Add%20an%20existing%20person%20as%20a%20child%20of%20the%20family%22,%22Add%20an%20existing%20repository%22,%22Add%20existing%20child%20to%20family%22,%22Add%22,%22Address%20Note%22,%22Addresses%22,%22Adopted%22,%22Adult%20Christening%22,%22After%22,%22Age%20at%20death%22,%22Age%22,%22Agency%22,%22Aide%22,%22Album%22,%22Also%20Known%20As%22,%22Alternate%20Marriage%22,%22and%22,%22Annulment%22,%22Archive%22,%22Association%20Note%22,%22Association%22,%22Associations%22,%22Attribute%20Note%22,%22Attributes%22,%22Audio%22,%22Author%22,%22Baptism%22,%22Bar%20Mitzvah%22,%22Bas%20Mitzvah%22,%22Before%22,%22Birth%20Date%22,%22Birth%20Name%22,%22Birth%20Place%22,%22Birth%22,%22Blessing%22,%22Book%22,%22Bookstore%22,%22Borough%22,%22Bride%22,%22Building%22,%22Burial%22,%22Calculated%22,%22Call%20name%22,%22Call%20Number%22,%22Cancel%22,%22Card%22,%22Caste%22,%22Cause%20Of%20Death%22,%22Cause%22,%22Celebrant%22,%22Cemetery%22,%22Census%22,%22Child%20Reference%20Note%22,%22Children%22,%22Christening%22,%22Church%22,%22Citation%22,%22Citations%22,%22City%22,%22Civil%20Union%22,%22Clear%22,%22Clergy%22,%22Collection%22,%22Complete%22,%22Con_fidence%22,%22Confidence:%22,%22Confidence%22,%22Confirmation%22,%22Country%22,%22County%22,%22Cremation%22,%22Custom%22,%22Dashboard%22,%22Database%20overview%22,%22Date%22,%22Death%20Date%22,%22Death%20Place%22,%22Death%22,%22Degree%22,%22Department%22,%22Description%22,%22Details%22,%22District%22,%22Divorce%20Filing%22,%22Divorce%22,%22done%22,%22Download%22,%22E-mail%22,%22Edit%20Citation%22,%22Edit%20Event%22,%22Edit%20Family%22,%22Edit%20Media%20Object%22,%22Edit%20Note%22,%22Edit%20Person%22,%22Edit%20Place%22,%22Edit%20Repository%22,%22Edit%20Source%22,%22Education%22,%22Elected%22,%22Electronic%22,%22Emigration%22,%22Enclosed%20By%22,%22Encloses%22,%22Engagement%22,%22Error%22,%22Estimated%22,%22Event%20Note%22,%22Event%20Reference%20Note%22,%22Event%20Type%22,%22Event%22,%22Events%22,%22Families%22,%22Family%20Note%22,%22Family%20Tree%22,%22Family%22,%22Farm%22,%22Father%20Age%22,%22Father%22,%22Female%22,%22Feudal%22,%22Fiche%22,%22File%22,%22Film%22,%22First%20Communion%22,%22Foster%22,%22FTP%22,%22Full%20Name%22,%22Gallery%22,%22Gender%22,%22General%22,%22Given%20name%22,%22Given%22,%22Graduation%22,%22Gramps%20ID%22,%22Groom%22,%22Hamlet%22,%22High%22,%22Home%20Page%22,%22Html%20code%22,%22Identification%20Number%22,%22Immigration%22,%22in%22,%22Informant%22,%22Inherited%22,%22Language%22,%22Last%20changed%22,%22Latitude%22,%22LDS%20Note%22,%22Library%22,%22Link%22,%22Loading%20items...%22,%22Locality%22,%22Location%22,%22Longitude%22,%22Low%22,%22Magazine%22,%22Male%22,%22Manuscript%22,%22Map%22,%22Marriage%20Banns%22,%22Marriage%20Contract%22,%22Marriage%20Date%22,%22Marriage%20License%22,%22Marriage%20Settlement%22,%22Marriage%22,%22Married%20Name%22,%22Married%22,%22Matrilineal%22,%22Matronymic%22,%22Max%20Ancestor%20Generations%22,%22Max%20descendant%20Generations%22,%22Media%20Note%22,%22Media%20Object%22,%22Media%20Objects%22,%22Media%20Reference%20Note%22,%22Media%22,%22Medical%20Information%22,%22Military%20Service%22,%22Mother%20Age%22,%22Mother%22,%22Municipality%22,%22Name%20Note%22,%22Name%22,%22National%20Origin%22,%22Naturalization%22,%22Neighborhood%22,%22New%20Citation%22,%22New%20Event%22,%22New%20Family%22,%22New%20Media%22,%22New%20Note%22,%22New%20Person%22,%22New%20Place%22,%22New%20Repository%22,%22New%20Source%22,%22New%20Tag%22,%22Newspaper%22,%22Next%22,%22Nick%20name%22,%22Nickname%22,%22No%20items%22,%22Nobility%20Title%22,%22None%22,%22Normal%22,%22Not%20found%22,%22Not%20Related%22,%22Note%22,%22Notes%22,%22Number%20of%20Children%22,%22Number%20of%20citations%22,%22Number%20of%20events%22,%22Number%20of%20families%22,%22Number%20of%20generations:%22,%22Number%20of%20individuals%22,%22Number%20of%20Marriages%22,%22Number%20of%20media%22,%22Number%20of%20notes%22,%22Number%20of%20people%22,%22Number%20of%20places%22,%22Number%20of%20repositories%22,%22Number%20of%20sources%22,%22Number%20of%20tags%22,%22Number%22,%22Occupation%22,%22Ordination%22,%22Page%22,%22Parents%22,%22Parish%22,%22Participants%22,%22Partner%22,%22Password:%22,%22Path%22,%22Patrilineal%22,%22Patronymic%22,%22People%22,%22Person%20Note%22,%22Person%22,%22Photo%22,%22Place%20Note%22,%22Place%22,%22Places%22,%22Prefix%22,%22Previous%22,%22Primary%22,%22Private%22,%22Probate%22,%22Property%22,%22Province%22,%22Pseudonym%22,%22Publication%20info%22,%22Quality%22,%22Range%22,%22References%22,%22Refresh%22,%22Region%22,%22Regular%22,%22Relationship%20to%20_Father:%22,%22Relationship%20to%20_Mother:%22,%22Relationship%20to%20home%20person%22,%22Relationship%20type:%22,%22Relationships%22,%22Religion%22,%22Report%22,%22Repositories%22,%22Repository%20Note%22,%22Repository%20Reference%20Note%22,%22Repository%22,%22Research%22,%22Reset%22,%22Residence%22,%22Retirement%22,%22Role%22,%22Safe%22,%22Second%20date%22,%22Select%20a%20file%22,%22Select%20a%20person%20as%20the%20father%22,%22Select%20a%20person%20as%20the%20mother%22,%22Select%20an%20existing%20media%20object%22,%22Select%20an%20existing%20note%22,%22Select%20an%20existing%20place%22,%22Select%20an%20existing%20source%22,%22Select...%22,%22Select%22,%22Selected%22,%22self%22,%22Set%20_Home%20Person%22,%22Share%20an%20existing%20event%22,%22Show%20Details%22,%22Siblings%22,%22Social%20Security%20Number%22,%22Source%20Note%22,%22Source%20Reference%20Note%22,%22Source%20text%22,%22Source:%20Author%22,%22Source:%20Title%22,%22Source%22,%22Sources%22,%22Span%22,%22Sponsored%22,%22Spouses%22,%22State%22,%22Statistics%22,%22Stepchild%22,%22Street%22,%22Suffix%22,%22Surname%22,%22Surnames%22,%22Tag%22,%22Tags%22,%22Taken%22,%22Text%22,%22This%20field%20is%20mandatory%22,%22Time%22,%22Timeline%22,%22Title%22,%22To%20Do%22,%22Tombstone%22,%22Town%22,%22Transcript%22,%22Type%22,%22Unknown%20%22,%22Unknown%22,%22Unmarried%22,%22Use%20Compression%22,%22Username:%20%22,%22Value%22,%22Very%20High%22,%22Very%20Low%22,%22Video%22,%22Village%22,%22Web%20Home%22,%22Web%20Search%22,%22Web%20site%22,%22Wife%22,%22Will%22,%22Witness%22,%22Zoom%22] net::ERR_CONNECTION_CLOSED

Above is from Vivaldi which apparently gives me a bit more detail.

DavidMStraub commented 2 years ago

And you can query that exact URL with curl just fine?

greenship24 commented 2 years ago

Somewhat. If I go to a main link like /api/translations, I can get it. If I put all that jibberish into a curl request then it does not work. I don't know if it's malformed or if it's just returning that in the console.

But I've tried many different API endpoints and all work and format fine via curl/httpie.

Some other errors I see are

83e2ff6a.js:4924 Uncaught (in promise) RuntimeError: abort(both async and sync fetching of the wasm failed). Build with -s ASSERTIONS=1 for more info.
    at B (83e2ff6a.js:4924:53518)
    at Z (83e2ff6a.js:4924:53810)
    at 83e2ff6a.js:4924:94827
83e2ff6a.js:322 
 GET https://familytree.example.com/api/translations/ net::ERR_CONNECTION_CLOSED
DavidMStraub commented 2 years ago

I suspect somewhere in your setup you have a limit on the maximum request length, see https://github.com/gramps-project/gramps-webapi/issues/225.

greenship24 commented 2 years ago

Oddly enough, Firefox and Vivaldi both throw errors. I'm trying Epiphany though and it seems fine. Still throws a "Error: Error 404" on every click but the information now loads.

On Firefox and Vivaldi the error is "Error: Network error". This is all going through the ingress. Very odd. I'll get some more time later to look at it and update if I find anything.

DavidMStraub commented 2 years ago

If it's the request length, it's not a browser issue, but e.g. with your proxy settings. This would also explain why

If I put all that jibberish into a curl request then it does not work.

greenship24 commented 2 years ago

If it's the request length, it's not a browser issue, but e.g. with your proxy settings. This would also explain why

If I put all that jibberish into a curl request then it does not work.

I should mention that when I curl the big long portion like that even via port-forward that the error is curl: (3) bad range specification in URL position 55:

I turned globbing off then got this.

curl: (92) HTTP/2 stream 1 was not closed cleanly before end of the underlying stream through the proxy whereas going through the port-forward it properly returns the request json.

Using curl with the --http1.1 flag though has it properly passing the json back same as it would through the port-forward. So if I force curl to use 1.1 then it is no different than localhost.

As it stands, there is an open issue to disallow http2 per host using an annotation on ingress-nginx. Looks like I'll have to disable http2 on the whole thing or perhaps deploy another ingress entirely for just this host.

I would think this basically solves the issue for someone using k8s and a relatively stock deployment of nginx-ingress.

DavidMStraub commented 2 years ago

OK, so the issue was that it doesn't work with HTTP/2, right? As far as I understand, this is a limitation of flask, so there is nothing we can do.

greenship24 commented 2 years ago

It appears so. And yes, short of replacing flask with quart (which appears possible but probably a big time investment all the same) then this really isn't possible.

Thank you for your help though David. I really appreciate it. If I get a working config (be it through another ingress application or what) then I'd like to contribute some generic Kubernetes (using Kustomize) templates.

If you're interested I can message you whenever I get it done and you can add them to the site. Thanks again.