标签: bad-gateway

aws lambda 上的无服务器收到内部服务器错误的 502 错误

我尝试将无服务器与 aws lambda 服务结合使用。

我的 serverless.yml 是:

service: webpack-4-example

# Add the serverless-webpack plugin
plugins:
  - serverless-webpack
  - serverless-offline

provider:
  name: aws
  runtime: nodejs8.10
  region: us-west-2
  stage: dev

package:
  individually: true

functions:
  first:
    handler: handlers/first.hello
    events:
      - http:
          method: get
          path: /first
  second:
    handler: handlers/second.hello
    events:
      - http:
          method: get
          path: /second

custom:
  webpack:
    webpackConfig: 'webpack.config.js'
    includModules: true
    packager: 'npm'
Run Code Online (Sandbox Code Playgroud)

我使用 serverless-webpack 和 serverless-offline 插件。

我只是为 first.js 编写了简单的无服务器

export const hello = async (event, context) => {
const rep = …
Run Code Online (Sandbox Code Playgroud)

node.js aws-lambda bad-gateway serverless

5
推荐指数
0
解决办法
1842
查看次数

30 秒后 502 网关错误

我网站上的一个页面需要在服务器上进行长时间的计算(约 2 分钟)。如果我在本地主机上运行该网站,它就可以正常工作。但在生产中大约需要 30 秒。这是我的 nginx conf 的 http 部分:

http {
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   120;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default …
Run Code Online (Sandbox Code Playgroud)

nginx gunicorn bad-gateway

5
推荐指数
1
解决办法
4625
查看次数

检查来自应用程序的 Internet 连接

在继续之前,我需要检查用户是否已连接到互联网。

我正在使用 HttpClient 访问端点,如下所示:

client := &http.Client{}
req, _ := http.NewRequest("GET", url, nil)
req.SetBasicAuth(username, password)
res, err := client.Do(req)

if err != nil {
    fmt.Println(err)
    ui.Failed("Check your internet connection")
}
Run Code Online (Sandbox Code Playgroud)

1) 在这种情况下,如果用户未连接到互联网,我需要向用户显示明确的消息,显示“请检查您的互联网连接”

2) 如果服务器没有响应,收到504 bad gateway,显示“504 Bad gateway”

有人可以帮助如何继续和区分这两种情况吗,我只想显示简单的消息,而不是从服务器收到的整个错误消息。

http go http-status-code-504 bad-gateway

3
推荐指数
2
解决办法
5839
查看次数

新 api 平台 docker-compose 上的 502 错误网关

我在 Digital Ocean 上有 docker,并且仍在尝试弄清楚如何使用 api 平台。所以我在端口 80 上的 api-platform-2.3.0 默认页面中的 docker-compose up 正常加载,但是当我转到 8080 时,它显示了错误的网关。所以我查了一下一切是否加载正常,看来 PHP 有问题。

\n\n
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                        PORTS                                                                    NAMES\n0a0c4724d2d5        api_h2-proxy                   "nginx -g \'daemon of\xe2\x80\xa6"   18 minutes ago      Up 18 minutes                 0.0.0.0:443-444->443-444/tcp, 80/tcp, 0.0.0.0:8443-8444->8443-8444/tcp   api_h2-proxy_1\n9958631ba1b8        quay.io/api-platform/varnish   "docker-varnish-entr\xe2\x80\xa6"   18 minutes ago      Up 18 minutes                 0.0.0.0:8081->80/tcp                                                     api_cache-proxy_1\n68de4a5058dd        quay.io/api-platform/nginx     "nginx -g \'daemon of\xe2\x80\xa6"   18 minutes ago      Up 18 minutes                 0.0.0.0:8080->80/tcp                                                     api_api_1\nf805ffdd804d        quay.io/api-platform/php       "docker-entrypoint p\xe2\x80\xa6"   18 minutes ago      Exited (126) 18 minutes ago                                                                            api_php_1\nb020f888b81d        postgres:9.6-alpine            "docker-entrypoint.s\xe2\x80\xa6"   19 …
Run Code Online (Sandbox Code Playgroud)

php docker docker-compose bad-gateway api-platform.com

1
推荐指数
1
解决办法
2915
查看次数