Setting Up a Free Pixiv Image Proxy with Cloudflare
1. Purchase a Domain
- Purpose: You need a domain name to host your proxy service.
- Recommended: Choose a cheap domain extension like
.xyz,.ga, or.cf.
2. Register Cloudflare Account
- Sign Up: Go to Cloudflare's official website and create an account.
- Login: Log in to your Cloudflare dashboard.
3. Add Site to Cloudflare
- Step 1: Click Add Site > Add a Site.
- Step 2: Enter your domain name (e.g.,
yourdomain.com) and click Next. - Step 3: Cloudflare will scan your domain's current DNS records. Click Continue Setup.
- Step 4: Choose Free Plan (the basic plan is sufficient for a proxy service).
- Step 5: Update DNS Nameservers:
- Your domain registrar (e.g., Alibaba Cloud) requires updating nameservers to Cloudflare's:
- Nameserver 1:
ns1.cloudflare.com - Nameserver 2:
ns2.cloudflare.com
- Nameserver 1:
- Follow your domain registrar's instructions to update nameservers. This step ensures Cloudflare manages your DNS.
- Your domain registrar (e.g., Alibaba Cloud) requires updating nameservers to Cloudflare's:
4. Configure DNS Records
- Proxy Settings: Go to the DNS tab in Cloudflare.
- Add a New A Record:
- Click Add Record > select A record.
- Fill in the fields:
- Name: Enter
pixiv(or a custom subdomain name, e.g.,proxy). - IPv4 Address: Enter any valid IP address (e.g.,
8.8.8.8for testing purposes). - TTL: Keep it as Auto (recommended).
- Name: Enter
- Enable Proxy Status:
- Check the box Proxy this record (the icon will turn orange).
- This enables Cloudflare's proxy for this subdomain.
- Save Changes:
- Click Save to apply the configuration.
5. Set Up Cloudflare Workers
- Go to Workers > Create a Worker.
- Create a New Service:
- Click Create a Worker.
- Name: Enter a name (e.g.,
pixiv-proxy). - Route: Set the route to
https://pixiv.yourdomain.com/*(replaceyourdomain.comwith your domain). - Click Create Service.
- Edit the Worker Code:
- Go to the Resources tab.
- Click Quick Edit to open the code editor.
- Replace the default code with the following script (explained below):
javascript
addEventListener('fetch', event => {
let url = new URL(event.request.url);
url.hostname = 'i.pximg.net';
let request = new Request(url, event.request);
event.respondWith(
fetch(request, {
headers:{
'Referer': 'https://www.pixiv.net',
'User-Agent':'Cloudflare Workers'
}
})
);
});6. Bind the Custom Domain
- Return to the Dashboard: Go back to the Cloudflare dashboard homepage.
- Select Your Worker: Navigate to Workers > Your newly created service (e.g.,
pixiv-proxy). - Add a Custom Domain:
- Click Add Custom Domain.
- Enter the subdomain you configured in the A record (e.g.,
pixiv.yourdomain.com). - Click Add Domain.
7. Test the Proxy
Example Test
- Pixiv Original Image Link:
https://i.pximg.net/img-original/img/2019/03/06/00/40/39/73532572_p0.jpg - Proxy Link:
https://pixiv.yourdomain.com/img-original/img/2019/03/06/00/40/39/73532572_p0.jpg - Access the Proxy Link: Open the modified link in a browser. If successful, the image should display.
Original post: https://www.theresa3rd.cn/#/imgProxy