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

[Bug] 请问vercel是不是被openai封ip了?用vercel部署的网页提交问题就报“Sorry, you have been blocked”,有什么办法解决么? #3286

Closed
3 tasks done
keney2023 opened this issue Nov 16, 2023 · 31 comments

Comments

@keney2023
Copy link

keney2023 commented Nov 16, 2023

为了提高交流效率,我们设立了官方 QQ 群和 QQ 频道,如果你在使用或者搭建过程中遇到了任何问题,请先第一时间加群或者频道咨询解决,除非是可以稳定复现的 Bug 或者较为有创意的功能建议,否则请不要随意往 Issue 区发送低质无意义帖子。

点击加入官方群聊

反馈须知

⚠️ 注意:不遵循此模板的任何帖子都会被立即关闭,如果没有提供下方的信息,我们无法定位你的问题。

请在下方中括号内输入 x 来表示你已经知晓相关内容。

  • 我确认已经在 常见问题 中搜索了此次反馈的问题,没有找到解答;
  • 我确认已经在 Issues 列表(包括已经 Close 的)中搜索了此次反馈的问题,没有找到解答。
  • 我确认已经在 Vercel 使用教程 中搜索了此次反馈的问题,没有找到解答。

描述问题
[Bug] 请问vercel是不是被openai封ip了有什么办法解决么?

如何复现
用vercel部署的网页提交问题就报“Sorry, you have been blocked”,

截图
请在此提供控制台截图、屏幕截图或者服务端的 log 截图。
图片

一些必要的信息

  • 系统:[比如 windows 10]
  • 浏览器: [比如 chrome]
  • 版本: [填写设置页面的版本号]
  • 部署方式:[比如 vercel部署]
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: [Bug] Is vercel’s IP blocked by openai? When submitting a problem on a webpage deployed with vercel, it reports "Sorry, you have been blocked". Is there any way to solve it?

In order to improve communication efficiency, we have set up an official QQ group and QQ channel. If you encounter any problems during use or construction, please join the group or channel for consultation as soon as possible, unless it is a bug that can be stably reproduced or More creative feature suggestions, otherwise please do not send low-quality and meaningless posts to the Issue area.

Click to join the official group chat

Feedback Instructions

⚠️ NOTE: Any post that does not follow this template will be immediately closed and we will not be able to locate your issue without providing the information below.

Please enter x in the square brackets below to indicate that you already know the relevant content.

  • I confirm that I have searched for the feedback issue in FAQ, and there is no find the solution;
  • I confirm that I have searched the Issues list (including those that have been Closed) for this feedback issue, but no answer has been found.
  • I confirm that I have searched for the feedback issue in Vercel usage tutorial. No answer found.

Describe the problem
[Bug] Is there any way to solve the problem of vercel being blocked by openai?

How ​​to reproduce
When submitting a problem using a webpage deployed with vercel, it will report "Sorry, you have been blocked".

screenshot
Please provide console screenshots, screenshots, or server-side log screenshots here.
Picture

Some necessary information

  • System: [such as windows 10]
  • Browser: [such as chrome]
  • Version: [Fill in the version number of the settings page]
  • Deployment method: [such as vercel deployment]

@jtv199
Copy link

jtv199 commented Nov 16, 2023

I am having the same issue. Also doesn't work when deployed to vercel. Works in codepod and I assume local.

@ventusff
Copy link

ventusff commented Nov 16, 2023

Managed to visualize the returned html message. It seems that the IP is banned due to attack protection.

image

@bruceye777
Copy link

我一个同事用用safari,报这个错,换成chrome好了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


A colleague of mine reported this error when using Safari. He changed it to Chrome.

@suoaao
Copy link

suoaao commented Nov 16, 2023

https://github.com/suoaao/affordable-openai

The self-reverse proxy can still be used after one iteration.

@jtv199
Copy link

jtv199 commented Nov 16, 2023

I don't think its browser dependent. The block is happening at open ai which means its blocked after vercel sends the data. I have tried edge, firefox and chrome, they are all blocked.

Below is a similar thread on the openai dev forums complaining about the same thing.

https://community.openai.com/t/api-access-failed-showing-cloudflare-block-page/506015/18

Potentially all vercel servers are blocked and and vercel has to negotiate with openai for renewed access.

@H0llyW00dzZ
Copy link
Contributor

H0llyW00dzZ commented Nov 16, 2023

that's proxy issue

works fine for me

image

proxy :

image

@bruceye777
Copy link

e40d7713-567f-44bf-8ad4-06b82bc5ec48
只要这个cdn 域名能够正常访问 就没有问题了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


e40d7713-567f-44bf-8ad4-06b82bc5ec48
As long as the cdn domain name can be accessed normally, there will be no problem.

@enzheng128
Copy link

Currently, OpenAI has blocked API access for all regions of Hong Kong. Vercel will pass through the user's IP to OpenAI's API, and if your IP is not from an allowed country, you will not be able to access it.

@ymd45921
Copy link

Currently, OpenAI has blocked API access for all regions of Hong Kong. Vercel will pass through the user's IP to OpenAI's API, and if your IP is not from an allowed country, you will not be able to access it.

How Vercel pass through user's IP? This project seems to use Vercel to provide a proxy for those blocked IPs?

@devyujie
Copy link

是不是CF的问题 noobnooc/noobnooc#9 (reply in thread)

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Is it a problem with CF noobnooc/noobnooc#9 (reply in thread)

@devyujie devyujie mentioned this issue Nov 16, 2023
3 tasks
@starsead
Copy link

we have the same issue too, and I check my CNAME record seems not proxy enabled, The value is cname.vercel-dns.com, so more like vercel's issue.

@pudd
Copy link

pudd commented Nov 17, 2023

在vercel.json中加入"regions": ["sin1"],可指定使用新加坡节点,避免自动使用了香港。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Add "regions": ["sin1"] to vercel.json to specify the Singapore node to avoid automatically using Hong Kong.

@devyujie
Copy link

在vercel.json中加入"regions": ["sin1"],可指定使用新加坡节点,避免自动使用了香港。

对的。noobnooc/noobnooc#9 (reply in thread)

@keney2023
Copy link
Author

在vercel.json中加入"regions": ["sin1"],可指定使用新加坡节点,避免自动使用了香港。

对的。noobnooc/noobnooc#9 (reply in thread)

测试可行

@Yidadaa
Copy link
Collaborator

Yidadaa commented Nov 17, 2023

fixed by #3290

@Yidadaa
Copy link
Collaborator

Yidadaa commented Nov 17, 2023

所有被此问题困扰的人,请手动更新代码,与主线保持同步。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Anyone who is troubled by this issue, please update the code manually to keep in sync with the mainline.

@fleetof
Copy link

fleetof commented Nov 17, 2023

在vercel.json中加入"regions": ["sin1"],可指定使用新加坡节点,避免自动使用了香港。

遇到同样的问题,用香港 IP 不可以但是美国的没有问题,看起来是我们自己直接请求的 OpenAI,屏蔽的是客户端的 IP。

但疑惑的是修改 vercel 节点也可以生效,就是说 vercel 转发了请求?既然转发了,那为啥非香港 IP 也可以访问呢,困惑

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Add "regions": ["sin1"] to vercel.json to specify the Singapore node to avoid automatically using Hong Kong.

Encountered the same problem, using the Hong Kong IP cannot work but the US has no problem. It seems that we directly requested OpenAI ourselves, and the client's IP is blocked.

But what is confusing is that modifying the vercel node can also take effect. Does it mean that vercel forwards the request? Since it is forwarded, why can non-Hong Kong IPs be accessed? Confused

@PEKEW
Copy link

PEKEW commented Nov 17, 2023

修改后仍然无效,尝试了sin1 和 cdg1:

{
    "github": {
        "silent": true
    },
    "headers": [
        {
            "source": "/(.*)",
            "headers": [
                {
                    "key": "X-Real-IP",
                    "value": "$remote_addr"
                },
                {
                    "key": "X-Forwarded-For",
                    "value": "$proxy_add_x_forwarded_for"
                },
                {
                    "key": "Host",
                    "value": "$http_host"
                }
            ]
        }
    ],
    "regions": ["cdg1"]
}

image



<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Attention Required! | Cloudflare</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" /><![endif]-->
<style>body{margin:0;padding:0}</style>


<!--[if gte IE 10]><!-->
<script>
  if (!navigator.cookieEnabled) {
    window.addEventListener('DOMContentLoaded', function () {
      var cookieEl = document.getElementById('cookie-alert');
      cookieEl.style.display = 'block';
    })
  }
</script>
<!--<![endif]-->


</head>
<body>
  <div id="cf-wrapper">
    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">
        <h1 data-translate="block_headline">Sorry, you have been blocked</h1>
        <h2 class="cf-subheadline"><span data-translate="unable_to_access">You are unable to access</span> api.openai.com</h2>
      </div><!-- /.header -->

      <div class="cf-section cf-highlight">
        <div class="cf-wrapper">
          <div class="cf-screenshot-container cf-screenshot-full">
            
              <span class="cf-no-screenshot error"></span>
            
          </div>
        </div>
      </div><!-- /.captcha-container -->

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="blocked_why_headline">Why have I been blocked?</h2>

            <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

            <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>
          </div>
        </div>
      </div><!-- /.section -->

      <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
  <p class="text-13">
    <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">82751d5ef2bb1053</strong></span>
    <span class="cf-footer-separator sm:hidden">&bull;</span>
    <span id="cf-footer-item-ip" class="cf-footer-item hidden sm:block sm:mb-1">
      Your IP:
      <button type="button" id="cf-footer-ip-reveal" class="cf-footer-ip-reveal-btn">Click to reveal</button>
      <span class="hidden" id="cf-footer-ip">2a06:98c0:3600::103</span>
      <span class="cf-footer-separator sm:hidden">&bull;</span>
    </span>
    <span class="cf-footer-item sm:block sm:mb-1"><span>Performance &amp; security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing" id="brand_link" target="_blank">Cloudflare</a></span>
    
  </p>
  <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script>
</div><!-- /.error-footer -->


    </div><!-- /#cf-error-details -->
  </div><!-- /#cf-wrapper -->

  <script>
  window._cf_translation = {};
  
  
</script>

</body>
</html>

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


修改后仍然无效,尝试了sin1 和 cdg1:

{
    "github": {
        "silent": true
    },
    "headers": [
        {
            "source": "/(.*)",
            "headers": [
                {
                    "key": "X-Real-IP",
                    "value": "$remote_addr"
                },
                {
                    "key": "X-Forwarded-For",
                    "value": "$proxy_add_x_forwarded_for"
                },
                {
                    "key": "Host",
                    "value": "$http_host"
                }
            ]
        }
    ],
    "regions": ["cdg1"]
}

image



<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Attention Required! | Cloudflare</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" />
<!--[if lt IE 9]><link rel="stylesheet" id='cf_styles-ie-css' href="/cdn-cgi/styles/cf.errors.ie.css" /><![endif]-->
<style>body{margin:0;padding:0}</style>


<!--[if gte IE 10]><!-->
<script>
  if (!navigator.cookieEnabled) {
    window.addEventListener('DOMContentLoaded', function () {
      var cookieEl = document.getElementById('cookie-alert');
      cookieEl.style.display = 'block';
    })
  }
</script>
<!--<![endif]-->


</head>
<body>
  <div id="cf-wrapper">
    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">
        <h1 data-translate="block_headline">Sorry, you have been blocked</h1>
        <h2 class="cf-subheadline"><span data-translate="unable_to_access">You are unable to access</span> api.openai.com</h2>
      </div><!-- /.header -->

      <div class="cf-section cf-highlight">
        <div class="cf-wrapper">
          <div class="cf-screenshot-container cf-screenshot-full">
            
              <span class="cf-no-screenshot error"></span>
            
          </div>
        </div>
      </div><!-- /.captcha-container -->

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="blocked_why_headline">Why have I been blocked?</h2>

            <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

            <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>
          </div>
        </div>
      </div><!-- /.section -->

      <div class="cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300">
  <p class="text-13">
    <span class="cf-footer-item sm:block sm:mb-1">Cloudflare Ray ID: <strong class="font-semibold">82751d5ef2bb1053</strong></span>
    <span class="cf-footer-separator sm:hidden">•</span>
    <span id="cf-footer-item-ip" class="cf-footer-item hidden sm:block sm:mb-1">
      Your IP:
      <button type="button" id="cf-footer-ip-reveal" class="cf-footer-ip-reveal-btn">Click to reveal</button>
      <span class="hidden" id="cf-footer-ip">2a06:98c0:3600::103</span>
      <span class="cf-footer-separator sm:hidden">•</span>
    </span>
    <span class="cf-footer-item sm:block sm:mb-1"><span>Performance & security by</span> <a rel="noopener noreferrer" href="https://www.cloudflare.com/5xx-error-landing" id="brand_link" target="_blank">Cloudflare</a></span>
    
  </p>
  <script>(function(){function d(){var b=a.getElementById("cf-footer-item-ip"),c=a.getElementById("cf-footer-ip-reveal");b&&"classList"in b&&(b.classList.remove("hidden"),c.addEventListener("click",function(){c.classList.add("hidden");a.getElementById("cf-footer-ip").classList.remove("hidden")}))}var a=document;document.addEventListener&&a.addEventListener("DOMContentLoaded",d)})();</script>
</div><!-- /.error-footer -->


    </div><!-- /#cf-error-details -->
  </div><!-- /#cf-wrapper -->

  <script>
  window._cf_translation = {};
  
  
</script>

</body>
</html>

@leo022
Copy link

leo022 commented Nov 17, 2023

modify /app/api/config/route.js:

import { NextRequest, NextResponse } from "next/server";

import { getServerSideConfig } from "../../config/server";

const serverConfig = getServerSideConfig();

// Danger! Do not hard code any secret value here!
// 警告!不要在这里写入任何敏感信息!
const DANGER_CONFIG = {
  needCode: serverConfig.needCode,
  hideUserApiKey: serverConfig.hideUserApiKey,
  disableGPT4: serverConfig.disableGPT4,
  hideBalanceQuery: serverConfig.hideBalanceQuery,
  disableFastLink: serverConfig.disableFastLink,
  customModels: serverConfig.customModels,
};

declare global {
  type DangerConfig = typeof DANGER_CONFIG;
}

// List of disabled regions
const DISABLED_REGIONS = ['HKG1'];

async function handle(request: NextRequest) {
  // Check if the region is disabled
  if (DISABLED_REGIONS.includes(request.cf.colo)) {
    return new NextResponse('Service not available in your region', { status: 403 });
  }

  return NextResponse.json(DANGER_CONFIG);
}

export const GET = handle;
export const POST = handle;

export const runtime = "edge";

@enzheng128
Copy link

image If the user's IP is in Hong Kong, access is also not possible. This is because Vercel, to ensure security, transmits the user's real IP to OpenAI's servers. When using Vercel, please make sure that your IP is in a region where OpenAI provides services. @Yidadaa

@devyujie
Copy link

感觉变慢了,是屏蔽香港服务器的问题吗

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


It feels slow. Is it a problem of blocking the Hong Kong server?

@H0llyW00dzZ
Copy link
Contributor

H0llyW00dzZ commented Nov 17, 2023

感觉变慢了,是屏蔽香港服务器的问题吗

yes, for me work's fine using singapore region (close to my country)

@Yidadaa Yidadaa closed this as completed Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests