How to serve gRPC and REST with TLS enable on the same port - rest

I'm trying to create a gRPC/REST PoC written in Go.
I would like to serve the gRPC and REST on the same port, in a TLS connection. I'm also using serving metrics.
When accessing my service through HTTP/1, all is working as expected
When accessing the /metrics url, all is working as expected
When accessing the gRPC service directly, using a client I received a connection close response
I do not know how to debug this kind of error.
I have created a repo on https://github.com/lrobinot/grpc-poc to reproduce the issue.
Can someone give me pointers to some resources or show me my enormous error :)
Thanks in advance!

Related

GET of JWKS_URI is failing when using angular-oauth2-oidc library

I am using angular-oauth2-oidc to connect to Keycloak server which is behind nginx.
I am using code flow for retrieving the token.
Even when using HTTP also, I see a GET request being sent for /protocol/openid-connect/certs
which is failing since the frontend APIs are having the correct hostname, but the backend APIs (jwks_uri) is having localhost.
Also, I am unable to set the KC_HOSTNAME_STRICT_BACKCHANNEL=true since the backend microservices will not be able to connect to Keycloak.
Is there a workaround for this.

Can Vapor 4 serve both HTTP and HTTPS requests in the same application?

I have a Vapor 4 app which is successfully serving HTTPS requests with no issues.
I would like it to also respond to HTTP requests on a custom port number, which will be for providing some back-end control and monitoring hooks that are called by other services on the same server, and won't be publicly reachable.
When I search Google and browse the Vapor docs for how to do this, I only get results for a very old version of Vapor, using a configuration file to specify HTTP/HTTPS server and port configurations.
Does anyone know if this type of configuration be done on Vapor 4?
Cheers and thanks in advance!
No Vapor 4 cannot serve different protocols on the same port/application. The easiest way around is to run two instances of the application, one for each. Or just get the internal traffic to use HTTPS.
Another option would be to stick Nginx in front or similar

Sending HTTP via proxy with haproxy

We have a company proxy (ip:port) and need to send HTTP POST with json payload to the URL like "http://server1.smthng.com/foo". Locally, name could not be resolved, but it is resolved at proxy. I dont understand how to configure haproxy to use proxy "ip:port" and send request without modifying the original URL.
I've tried curl to "http://server1.smthng.com/foo" after setting https_proxy variable from CLI (in linux) and it worked for me, so now I need to replicate same via haproxy.
From curl logs I could see that it first makes a CONNECT to proxy and once connection is there it POSTs the data.
I could be missing some knowledge here regarding tcp tunnels and the answer could be simple really. Anyway, need help.
The question is to be closed with no asnwer. The solution we took is via civetweb htt_proxy parameters.

Connect HttpResolver to API using custom port

Hello: I'm creating an Appsync endpoint to gradually upgrade all of our old Rest API to GraphQL. In our API we aggregate data from some third party services (also REST).
One of those services has an endpoint running in a custom port (let's say 8050) and while our initial idea was to use Appsync HTTP Resolvers to connect to it we've been experiencing timeout problems. Our provider says there is nothing wrong with it's service but I've searched Amazon Appsync docs and there's nothing there about ports.
Has anyone else experienced this issue and knows how to solve it?
Thanks in advance.
When configuring your HTTP Data source, you can append the port to the HTTP Endpoint URL. See below.
As of May 2021, I tried to specify the port number in HTTP Endpoint URL in the Data Source configuration UI, it didn't work. I still received the timeout error.
Since I have control to the HTTP API server, I changed the server to listen on port 80, removed port number from the datasource HTTP endpoint config, and things start to work. It seems as of now, appsync does not support listening on ports other than 80 for http.

REST API with Single Page Application over HTTPS on Firefox only

I am developing a web service using REST API. This REST API is running on port 6443 for HTTPS. Client is going to be a Single page application running on port 443 for HTTPS on same machine. The problem I am facing is:
While I hit the url say: https://mymachine.com/new_ui I get certificate exception for an invalid certificate because I use a self signed one, so mymachine.com:443 gets added to server exception. But still requests doen't go to REST API as they are running on https://mymachine.com:6443/restservice. If I manually add mymachine.com:6443 to server exception on firefox it works but it will not be the case in production for customers.
Some options that I thought are:
1. Give another pop up and ask to add REST server on port 6443 exception too.But this doesn't look proper as why an end user should accept the cerf for same domain twice. Also REST api server port can change.
Can we programmatically add exception for domain and both the ports in one shot? Ofcourse with the consent of the user. 3. Use a reverse proxy. But then its going to have memory footprint on our system. Also it will be time consuming.
Please suggest some options. How do I deal with it. Thank you