@gayanw in a world of reverse proxies and all other infrastructure that can lie between a client and server, I think you are better off reading the rest ws URL GP value and pull the details from it.
webservices.rest.uriPrefix
is being used before. What it returns is “http://127.0.0.1/openmr…”
Lets try Cintia’s suggesstion.
I undestand the difference between “running server” and the URL the user requested. I thought it was the first case (the URL rarely is useful, specially when you have a load balancer).
In my case I use InetAddress.getLocalHost for troubleshooting, we deploy by default in a cluster of 3 JBoss and an Apache load balancer and sometimes it’s relevant to know the physical machine where an exception is thrown. For instance, if there’s a problem on file permissions. Showing a message to the user is faster than checking multiple logs.
Because you have not set the correct GP value, it should return whatever value it’s set to, make sure it’s configured first
We merged the PR. Now host
returns “qa-refapp.openmrs.org” which is correct. But the scheme still returns “http”. I think that is because the request.getHeader(HttpHeaders.X_FORWARDED_PROTO)
still returns null.
@cintiadr any suggestions to get the scheme
property right?
There was clearly an error on my side, I didn’t spot it before.
It was hardcoding the header to be ‘http’. Can you retry now?
It still is http
though. You can check it in here. Please see the value of the “schemes” property there.
The code is:
Look, I have no idea why. But it appears that if I try to add that specific header on the main http nginx configuration, it doesn’t work.
If I add it inside each nginx location configuration, it works: https://qa-refapp.openmrs.org/openmrs/module/webservices/rest/swagger.json
location /openmrs {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8080/openmrs;
}
There’s some sort of lesson in here I’m pretty sure, but it’s late and I’ll leave that for another day. … and it’s working.
Now the schemes
is correct. But the host
param is back to old 127.0.0.1:8081
OMG. See, there’s a lesson here
I’m going to add host to the location. Should fix it.
I think it’s good now.