You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

局域网内搭建自有推送服务及修改浏览器endpoint URL可行性问询

How to Redirect Browser Endpoint Requests to an Internal Web Service

Great question—dealing with air-gapped LAN environments where you can’t rely on external services is super common, and you don’t need a custom browser to make this work. Here are the most practical approaches:

1. Use a Local Reverse Proxy

Set up a lightweight proxy server on the same network (or even the same machine as your app) to intercept requests meant for the browser vendor’s endpoint and forward them to your internal service. This works for any browser without modifying its core behavior.

For example, with Nginx, you can add a configuration like this to nginx.conf:

server {
    listen 80;
    server_name browser-vendor-endpoint.com; # Match the original endpoint's domain

    location / {
        proxy_pass http://your-internal-service-ip:port; # Your internal service's address
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Then update your app to send requests to this proxy (or pair it with the hosts trick below to automatically route the original domain to the proxy’s IP).

2. Build a Minimal Browser Extension

Most modern browsers (Chrome, Firefox, Edge) let you create tiny extensions that intercept and modify HTTP requests. This is perfect because you don’t need to recompile the browser—just install the extension locally on each machine.

Here’s a quick example for Chrome:

  • Create a manifest.json file:
{
    "manifest_version": 3,
    "name": "Internal Endpoint Redirector",
    "version": "1.0",
    "permissions": ["declarativeNetRequest"],
    "host_permissions": ["*://browser-vendor-endpoint.com/*"],
    "background": {
        "service_worker": "background.js"
    }
}
  • Create a background.js file to handle redirection:
chrome.declarativeNetRequest.updateDynamicRules({
    addRules: [
        {
            id: 1,
            priority: 1,
            action: {
                type: "redirect",
                redirect: {
                    url: "http://your-internal-service-ip:port/"
                }
            },
            condition: {
                urlFilter: "*://browser-vendor-endpoint.com/*",
                resourceTypes: ["xmlhttprequest", "script"]
            }
        }
    ]
});

Zip these files and load the extension into Chrome via "Load unpacked" in the extensions settings. This will automatically redirect any requests to the original endpoint to your internal service.

3. Modify the Hosts File

If the browser’s endpoint uses a public domain (e.g., api.browser-vendor.com), you can edit your machine’s hosts file to map that domain to your internal service’s IP address. This tricks the browser into sending requests to your local service instead of the external one.

  • On Windows, edit C:\Windows\System32\drivers\etc\hosts
  • On Linux/macOS, edit /etc/hosts

Add a line like:

192.168.1.100    api.browser-vendor.com

Replace 192.168.1.100 with your internal service’s IP. Note: If the original endpoint uses HTTPS, you’ll need to install a trusted SSL certificate for the domain on your internal service (temporarily disabling SSL verification is not recommended for production).

4. Adjust Your App’s Request Logic (If Possible)

If your application is under your control, consider modifying it to send POST requests directly to your internal service instead of relying on the browser’s endpoint. This cuts out the middleman entirely and is the cleanest solution if you can update the app’s code.

Each approach has its tradeoffs: proxies work for network-wide changes, extensions are browser-specific but easy to deploy, hosts files are simple but per-machine, and app modifications are the most straightforward if feasible. Pick the one that fits your LAN setup best!

内容的提问来源于stack exchange,提问作者R0byn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 10:22:35