# How To Proxy Any Website ⭐

**URL:** <https://onehack.st/t/how-to-proxy-any-website/305923>\
**Category:** Tutorials & Methods\
**Tags:** privacy, tips-tricks\
**Created:** [June 2, 2025, 8:18pm UTC](https://onehack.st/t/how-to-proxy-any-website/305923 "2025-06-02T20:18:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aina](https://onehack.st/user_avatar/onehack.st/aina/32/167469_2.png) [@Aina](https://onehack.st/u/Aina)\
**Post date:** [June 2, 2025, 8:18pm UTC](https://onehack.st/t/how-to-proxy-any-website/305923/1 "2025-06-02T20:18:51Z")

</div>

How To Proxy Any Website ⭐

This guide provides step-by-step instructions for setting up a proxy and using it to access any website you want, regardless of regional restrictions and censorship. FYI, not all websites can be proxied using this method.

* * *

1. **Sign** up on [https://www.cloudflare.com/](https://www.cloudflare.com/) if not already.
2. **Click** on workers tab.
3. **Choose** a subdomain where you would like to see your workers.

- \*such as zyx.subdomain.workers.dev
- \*here zyx will be replaced by your future worker names.
- \*the subdomain will stay same for all future workers.

1. **After** selecting subdomain click on create a service/worker.
2. **Name** your new worker anything you want.
3. **Click** create.
4. **Click** quick edit.
5. **Click** next.
6. **Delete** existing code.
7. **Paste** the provided code from below there.
8. **Use** the instructions provided underneath.

- Two sets of code have been provided.
- Try the Code I first.
- If it doesn’t work, try Code II.
- If both don’t work, website can’t be proxied using this method.

* * *

What To Modify In The Code?

- **Replace** 1337x with whatever you named your new worker.
- **Replace** subdomain with whatever you set your subdomain to.
- **Replace** 1337x.to with the website you want to be proxied.
- **Don’t** enter [https://1337x.to/](https://1337x.to/)
- **Only** 1337x.to

* * *

**Code I**

```auto
async function handleRequest(request) {
const url = new URL(request.url)
let response

// Check if the hostname is present in the ORIGINS object
if (url.hostname in ORIGINS) {
  const target = ORIGINS[url.hostname]
  url.hostname = target
  response = await fetch(url.toString(), {
      method: request.method,
      headers: request.headers
  })
} else {
  response = await fetch(request)
}
return new HTMLRewriter()
  .on('a', new LinkHandler(url))
  .on('form', new FormHandler(url))
  .on('*', new ElementHandler(url, ORIGINS))
  .transform(response)
}

class LinkHandler {
constructor(baseUrl) {
  this.baseUrl = baseUrl
}

element(element) {
  let href = element.getAttribute('href')
  if (href) {
      element.setAttribute('href', new URL(href, this.baseUrl).pathname + new URL(href, this
          .baseUrl).search)
  }
}
}

class FormHandler {
constructor(baseUrl) {
  this.baseUrl = baseUrl
}

element(element) {
  let action = element.getAttribute('action')
  if (action) {
      element.setAttribute('action', new URL(action, this.baseUrl).pathname + new URL(action, this
              .baseUrl)
          .search)
  }
}
}

class ElementHandler {
constructor(url, ORIGINS) {
  this.url = url
  this.ORIGINS = ORIGINS
}
element(element) {
  if (element.tagName === 'script' || element.tagName === 'link' || element.tagName === 'img') {
      let src = element.getAttribute('src') || element.getAttribute('href')
      if (src) {
          let srcUrl = new URL(src, this.url)
          if (srcUrl.hostname in this.ORIGINS) {
              let target = this.ORIGINS[srcUrl.hostname]
              srcUrl.hostname = target
          }
          element.setAttribute(element.tagName === 'script' ? 'src' : 'href', srcUrl.toString())
      }
  }
}
}

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

const ORIGINS = {
'1337x.subdomain.workers.dev': '1337x.to'
}

```

**Code II**

```auto
async function handleRequest(request) {
const url = new URL(request.url)
if (url.hostname in ORIGINS) {
const target = ORIGINS[url.hostname]
url.hostname = target
return fetch(url.toString(), request)
}
return fetch(request)
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
 
const ORIGINS = {
'1337x.subdomain.workers.dev': '1337x.to'
}   

```

## ENJOY & HAPPY LEARNING! ❤

Appreciate the share, Don’t be cheap!

I aim to provide the best of the best, trusted, reliable, and useful content that could!
