Skip to content
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

404 Error: getaddrinfo ENOTFOUND https https: 80 #201

Closed
ctwh opened this issue Oct 21, 2019 · 3 comments
Closed

404 Error: getaddrinfo ENOTFOUND https https: 80 #201

ctwh opened this issue Oct 21, 2019 · 3 comments
Labels

Comments

@ctwh
Copy link

ctwh commented Oct 21, 2019

Hello,

I have Cors-anywhere hosted in a docker container on a server that receives traffic directed as a rewrite from another container running apache. The apache container runs a web app, and upon being loaded in the browser, sends requests via a proxy to cors-anywhere like:

https:///cors-anywhere/https://.../

A simple rewrite rule in the apache container directs traffic to the container running cors-anywhere:

RewriteRule "^/cors-anywhere/(.*)$" "http://${CORS_ANYWHERE_SERVER_HOST}:${CORS_ANYWHERE_SERVER_PORT}/$1" [P,NC,L]

When run locally, everything works fine. However, when hitting the server, I get this response:

Not found because of proxy error: Error: getaddrinfo ENOTFOUND https https: 80

I am aware that an issue was raised with an identical error, but I don't know how to address it in apache. Furthermore, I don't necessarily think the causes are the same either.
Possible related issue #167

@Rob--W
Copy link
Owner

Rob--W commented Oct 21, 2019

The issue is the same: You're using normalized URLs.
You should be looking for the raw values instead. I suppose that you can reconstruct the raw URL with %{REQUEST_URI} and %{QUERY_STRING} or even %{THE_REQUEST} (in RewriteCond) and then refer to the captured groups from the regexp with %1, %2, etc.

See the documentation at https://httpd.apache.org/docs/current/mod/mod_rewrite.html#RewriteCond

@ctwh
Copy link
Author

ctwh commented Oct 23, 2019

Thank you, @Rob--W !

My solution:

RewriteCond "%{REQUEST_URI}" "\/cors-anywhere\/https:\/(.*)"
RewriteRule "^/cors-anywhere/(.*)$" "http://${CORS_ANYWHERE_SERVER_HOST}:${CORS_ANYWHERE_SERVER_PORT}/https://%1" [P,NC,L]

Note above that RewriteCond still requires searching against a single slash (https:/) instead of (https://). If you use %{THE_REQUEST} it will be a raw url (requiring you to search for https://). The %{REQUEST_URI} I am using will also include query params for me.

Furthermore, I was not able to stack RewriteCond lines and extract multiple capture groups for each line and having a reference to them (e.g. using %1 for a capture group for the first RewriteCond, %2 for the second RewriteCond). That approach did not work, so my solution was driven by that limitation.

@a0309nkita
Copy link

Hi!

I'm working on angular project and from there I'm trying to post some logs to a server, but while hitting that server I got CORS error, and on searching I found that if I append https://cors-anywhere.herokuapp.com with my URL it'll work.

So after adding it my CORS error gone but now I'm getting proxy error like this:- Not found because of proxy error: Error: getaddrinfo ENOTFOUND ..com.

This is my code snippet
const response: any = await axios.post(LOGNESS_LOG_EVENT_URL, event, {
headers: EVENT_HEADERS(bearer),
});

and my LOGNESS_LOG_EVENT_URL is as :- https://cors-anywhere.herokuapp.com/https://********.

Please provide soln to this as I got stuck here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants