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

A Suggestion about your China CDN #9291

Closed
BROBIRD opened this issue Apr 25, 2019 · 5 comments
Closed

A Suggestion about your China CDN #9291

BROBIRD opened this issue Apr 25, 2019 · 5 comments
Labels
a:feature A new functionality

Comments

@BROBIRD
Copy link

BROBIRD commented Apr 25, 2019

Expected Behavior

An automated redirection from https://services.gradle.org/distributions/<something>.zip or https://downloads.gradle.org/distributions/<something>.zip to China CDN https://downloads.gradle-dn.com/distributions/<something>.zip

Current Behavior

Just a Cloudflare CDN, very slow in China.

Context

I think it's better to redirect the download links to China CDN for users in China.
Cloudflare provides a function named IP Geolocation, so I think you can set some redirect rules using the header CF-IpCountry so that we users will not need to modify the file gradle\wrappers\gradle-wrapper.properties or download the .zip files manually.

I think there are two options:

  1. Configure redirection rules on your original server.
  2. Use the Workers function provided by Cloudflare.

example code:

addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  let url = new URL(request.url)
  if (url.pathname == "/") {
    let country = request.headers.get("CF-IpCountry")
    if(country=="CN"){
      url.host = "test.example.com"
    }
    return Response.redirect(url, 302)
  }
}
@BROBIRD BROBIRD added the a:feature A new functionality label Apr 25, 2019
@wusatosi
Copy link

agree!

@ldaley
Copy link
Member

ldaley commented Jul 29, 2019

The redirect was not in place due to a regression. It is now fixed. Please try again.

@wusatosi
Copy link

The redirect was not in place due to a regression. It is now fixed. Please try again.

image
image

I can confirm the redirect and downloads.gradle-dn.com is working and serving within China!

The cache is cold though, I think Cloudflare will handle it soon 😄
image

Thanks for the excellent work

@ldaley
Copy link
Member

ldaley commented Jul 29, 2019

Thanks for confirming.

@ldaley ldaley closed this as completed Jul 29, 2019
@wusatosi
Copy link

Thanks for confirming.

Thanks for you guys' great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality
Projects
None yet
Development

No branches or pull requests

3 participants