ReverseProxy | Simple C # reverse proxy | Proxy library
kandi X-RAY | ReverseProxy Summary
kandi X-RAY | ReverseProxy Summary
A simple C# reverse proxy. It will redirect all TCP traffic from one port to another IP/port destination. Traffic can also be distributed to multiple destinations. In this case each connection is sent to one of the destination in a round-robin fashion.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ReverseProxy
ReverseProxy Key Features
ReverseProxy Examples and Code Snippets
Community Discussions
Trending Discussions on ReverseProxy
QUESTION
I am trying to implement a Reverse Proxy in Go that proxies traffic to different hosts based on some tenant embedded in the URL. The implementation looks like this:
...ANSWER
Answered 2022-Apr-05 at 11:20The problem is that in the scenario where a previous proxy already existed, you first pass the request on to that - and then still recreate the proxy, and again pass the request. In other words: you are making two proxied requests for each incoming request, when the tentantProxyMap is already populated for that tenant.
The ReverseProxy
implementation closes the req.Body
, so the second time you pass the request on to the proxy, it attempts reading from an already closed body. You're seeing the http: invalid Read on closed Body
error as a result.
What you should try is to return after proxying the request, e.g. by adding a return
:
QUESTION
I have run in to this issue twice.
The first time was with a reverse proxy that lived inside an IPv6 only server network. Client requests come in through NAT46. The source-IP of the request becomes [fixed 96-bit prefix] + [32-bit client IPv4 address]. This means that the reverse proxy could always identify the real client IP. I couldn't find a way to set the X-Forwarded-For
header to that address though. I got around it by modifying the backend server.
This time I have a reverse proxy which will run on Google App Engine. Requests hit Google's load balancer first, which adds the X-Forwarded-For
header and forwards the request to my app. I want to modify the request a bit and then pass it to a backend server, which I cannot modify. The back-end needs the original client IP, and can accept it via X-Forwarded-For
(it's authenticated, don't worry). In this case I want to pass the X-Forwarded-For
header from Google's load balencer through unmodified.
It seems like there is no way to set X-Forwarded-For
to a value that I chose when using httputil.ReverseProxy
. If I set it (option 1 below) the client address from the TCP connection will be appended. If if I set it to nil
(option 2 below), it is omitted like the documentation suggests, but that's not what I want either.
ANSWER
Answered 2022-Apr-02 at 06:33I believe you have two options.
1. Implementhttp.RoundTripper
You implement your own RoundTripper
and re-set X-Forwarded-For
in there. (demonstration)
QUESTION
When messing around with Go's http/httputil.ReverseProxy, listening on a local address with a zone, making a request through it locally, including the zone, I've seen that the zone identifier ends up in the X-Forwarded-For
header added by the reverse proxy. (You can see it occur around here. SplitHostPort
leaves the zone intact.)
Should the zone be in the XFF IP? Does it make sense? Is it a bug?
My not-very-clear understanding of zone identifiers is that it doesn't make sense outside of the particular machine that's using it. On the other hand, maybe if you're trying to trace the path a request took, the zone is necessary to disambiguate?
...ANSWER
Answered 2022-Mar-24 at 15:53After thinking about this for a while, I ended up writing a blog post about it. Here is the conclusions section of that post:
Zones should be kept until the point of use, and then the decision to keep or strip them should be based on the specific use of the IP and ramifications of zones to that use.
This means that reverse proxies should be including the zone in the X-Forwarded-For
header, rate limiters should probably be discarding them, and prefix-contains-IP checks should be based on whether there's a zone in the prefix. But these are only examples -- there are myriad uses of IP addresses, and the particular use will dictate (or at least inform) the fate of the zone.
Of course, this is all debatable. To see some other other opinions, check out the few comments I got when I asked about this in the r/ipv6 subreddit. If you have a differing opinion or know of anyone else having written about this, please let me know.
QUESTION
I am wondering if it would be possible to cancel a web request or send an internal response to the client inside the ReverseProxy.Director
function.
Suppose we do something that throws an error, or we have other reason to not forward the request.
...ANSWER
Answered 2022-Feb-26 at 07:31if it would be possible to cancel a web request [...]
You can cancel the request that is passed to the Director
function, BUT there are some details to consider:
- the correct way to cancel a request is to cancel its context
- you can not cancel contexts where you didn't set a (deadline|timeout|cancelfunc) yourself → i.e. you must have access to the
cancel
function → i.e. you can't cancel parent contexts created by someone else. - the
*http.Request
passed toDirector
function is a clone of the original request
Based on the points above, you can replace the request in the Director
with another one that has a cancellable context. It may look like the following:
QUESTION
updated:
To reproduce the issue is very simple with a few steps:
- Install it on your Ubuntu server by running the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
During the auto installation process, you will be prompted to enter the domain for your Posthog site, so enter one and wait for the process to finish.
Visit the domain you entered and it is accessbile.
Now reboot your VPS and visit the domain again it is down forever. Not accessbile even if you use your vps ip address.
I've tried this auto-installation and reboot thing three times on the same vps and ended up with the same result. I've also tried it on another vps by a new hosting provider, yet still the same issue. Fresh installation and the site will be down right after your reboot your vps!
The following is the error log I got from the Caddy container, which is generated after the vps reboot:
{"level":"error","ts":1642534398.9394724,"logger":"http.log.error","msg":"dial tcp 172.18.0.4:8000: connect: connection refused","request":{"remote_addr":"67.198.228.123:35424","proto":"HTTP/2.0","method":"GET","host":"","uri":"/preflight","headers":{"Sec-Ch-Ua":["" Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96""],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"],"Sec-Fetch-Site":["cross-site"],"Accept-Language":["en-US,en;q=0.9"],"Accept-Encoding":["gzip, deflate, br"],"Cookie":["phtoolbar=yes; csrftoken=gsVfpdF56rbYgQQdwywH45zi83i386oe5KZZef3mIE00bumaQCG3i4OM35bdJIxQ; ph_sTMFPsFhdP1Ssg_posthog=%7B%22distinct_id%22%3A%22FpLgrw74q9qcclLSJ1bOrzsiPJmZtHdKswxemTFy9LG%22%7D"],"Cache-Control":["max-age=0"],"Sec-Ch-Ua-Mobile":["?0"],"Upgrade-Insecure-Requests":["1"],"Sec-Fetch-Dest":["document"],"Sec-Ch-Ua-Platform":[""macOS""],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Mode":["navigate"],"Sec-Fetch-User":["?1"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":""}},"duration":0.008754516,"status":502,"err_id":"gicbjv2m4","err_trace":"reverseproxy.statusError (reverseproxy.go:886)"} {"level":"error","ts":1642534401.5881941,"logger":"http.log.error","msg":"dial tcp 172.18.0.4:8000: connect: connection refused","request":{"remote_addr":"67.198.228.123:35424","proto":"HTTP/2.0","method":"GET","host":"","uri":"/preflight","headers":{"Cache-Control":["max-age=0"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":[""macOS""],"Sec-Fetch-User":["?1"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"],"Sec-Ch-Ua":["" Not A;Brand";v="99", "Chromium";v="96", "Google Chrome";v="96""],"Sec-Fetch-Mode":["navigate"],"Accept-Encoding":["gzip, deflate, br"],"Upgrade-Insecure-Requests":["1"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-Dest":["document"],"Accept-Language":["en-US,en;q=0.9"],"Cookie":["phtoolbar=yes; csrftoken=gsVfpdF56rbYgQQdwywH45zi83i386oe5KZZef3mIE00bumaQCG3i4OM35bdJIxQ; ph_sTMFPsFhdP1Ssg_posthog=%7B%22distinct_id%22%3A%22FpLgrw74q9qcclLSJ1bOrzsiPJmZtHdKswxemTFy9LG%22%7D"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":""}},"duration":0.001907749,"status":502,"err_id":"27e15xwsj","err_trace":"reverseproxy.statusError (reverseproxy.go:886)"}
By the way, this is their documentaion page FYI: https://posthog.com/docs/self-host/deploy/hobby
Original question:
I've installed Posthog with their so-called hobby installation script on my vps and at first it was working fine. But right after I rebooted ubuntu and visited my self-hosted posthog site again, it would not load and just showed a blank page. It seems that something went wrong after I rebooted my vps. I've checked all the services required by Posthog with the command docker ps, and everything is up and running(check the screenshot attached).
I've been trying to figure it out for 4 days yet with no luck. I am new to docker and kubernetes so I do not know what causes the problem and what I should do. Please shed some light on this and help me :(
...ANSWER
Answered 2022-Feb-07 at 09:08First things first, this is a docker-compose stack, not Kubernetes.
If you take a look at the script you execute, you can see that it's downlowading docker compose and then uses it to start up your stack.
As such, executing docker-compose stop && docker-compose start
after your rebooted should fix this.
The "problem" here is the docker compose yaml that is used for the hobby project, which includes the following:
QUESTION
I am building a web application with ASP.NET Core 6.
I have:
- Frontend.Client - a Blazor WebAssembly with the UI
- Frontend.Server - ASP.NET Core, hosting the Blazor WebAssembly
- Web Api - a remote REST Service
- gRpc Service - a remote gRpc Service
- Identity Provider - a Duende project using Duende.Bff.Yarp
My Frontend.Client is configured to call its own BFF (the Frontend.Server), while the server forwards the calls to the REST and gRpc services using Duende.Bff.YARP.
The calls to the REST service work as expected: the client passes the token automatically as by documentation.
My problem is with the calls to gRpc, which don't seem to use the correct HttpClient with the AntiForgeryToken and the Access Token as it should.
I know I'm missing some setting somewhere but I can't find any example on how to use Duende with a gRpcWebClient.
My Frontend.Client configuration contains:
...ANSWER
Answered 2022-Feb-04 at 07:27The problem was the AntiforgeryHandler, since I had not added it to the chain of the HttpHandlers of my gRpcChannel. What I did to solve it was
- Add a constructor to my AntiforgeryHandler to accept an innerhandler and pass it to its base class
- Attach my AntiforgeryHandler to the chain of HttpHandlers turing the construction of the grpc client
The AntiforgeryHandler becomes:
QUESTION
I am trying to use Yarp in my gateway app for routing my applications. However as soon as it's started, I get "Route '0' requires Hosts or Path specified. Set the Path to '/{**catchall}' to match all requests."
Here is my AppSettings file:
...ANSWER
Answered 2021-Dec-25 at 11:22There was a breaking changes in v1.0.0-preview11 for the way Routes
are configured. You need to update your setting.
QUESTION
I have a reverse proxy server using Vert.x Web Proxy, implemented with pretty standard code:
...ANSWER
Answered 2021-Nov-23 at 19:11The answer to this question is simple: do not use HttpProxy if you want to capture responses.
After looking through the Vertx Web Proxy source code, it became clear to me that the HttpProxy has no capability for capturing responses. It became necessary to implement a web proxy that did so.
I assimilated the bulk of the Vertx Web Proxy code into my application, and created a proxy library that not only captures responses but captures requests as well. The new web proxy, called F3WebProxy, has lambdas that allow for coding custom actions when a proxy begins processing a request, and coding custom actions when the response is received. The interface is very simple and easy to use.
QUESTION
I'm implementing a simple reverse proxy in Python3 and I need to send a response with transfer-encoding chunked
mode.
I've taken my cues from this post but I have some problems when sending the chunks in the format described here
If I send chunks of length <= 9 bytes the message is received correctly by the client, otherwise when sending chunks of length >= 10 bytes, it seems that some of them are not received and the message remains stuck in the client waiting indefinitely
Here is an example of non working code:
...ANSWER
Answered 2021-Oct-20 at 07:42I post the solution (thanks to Martin Panter from bugs.python.org) in case anyone else will have the same problem in the future.
The behaviour was caused by the chunk size part, that must be in hex format, not decimal.
Unfortunately from the Mozilla docs the format was not specified and the example used only length < 10. A formal definition is found here
In conclusion, the working version is the following (using {0:x}
instead of {0:d}
)
QUESTION
After deploying to AWS EKS
I get this error
Gtihub repo: https://github.com/oussamabouchikhi/udagram-microservices
Steps to reproduce
- Create
AWS EKS
cluster and node groups - Configure
EKS
cluster withkubectl
- Deploy to
EKS
cluster (secrets first, then other services, then reverserproxy)
.kubectl apply -f env-secret.yaml
.kubectl apply -f aws-secret.yaml
.kubectl apply -f env-configmap.yaml
. ...
.kubectl apply -f reverseproxy-deployment.yaml
.kubectl apply -f reverseproxy-service.yaml
nginx-config
...ANSWER
Answered 2021-Oct-09 at 10:57resolver
in nginx
config
The nginx
resolver
directive is required.
Nginx is a multiplexing server (many connections in one OS process), so each call of system resolver will stop processing all connections till the resolver answer is received. That's why Nginx implemented its own internal non-blocking resolver.
If your config file has static DNS
names (not generated), and you do not care about track IP changes without nginx reload
, you don't need nginx
's resolver. In this case all DNS
names will be resolved on startup.
Nginx
's resolver
Nginx
resolver
directive should be used, if you want to resolve domain name in runtime without nginx
reload.
E.g.:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ReverseProxy
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page