相关疑难解决方法(0)

如何解决Nginx"proxy_pass 502 Bad Gateway"错误

我试图在我的nginx.conf文件中添加proxy_set_header.当我尝试添加proxy_pass并调用URL时,它会抛出502 Bad Gateway nginx/1.11.1错误.

不确定如何解决此错误:

upstream app-server {
    # connect to this socket
    server unix:///tmp/alpasso-wsgi.sock;    # for a file socket
}

server {
    server_name <name>;

    listen 80 default_server;

    # Redirect http to https
    rewrite ^(.*) https://$host$1 permanent;
}

server {
    server_name <name>;

    listen 443 ssl default_server;

    recursive_error_pages on;

    location /azure{
        proxy_pass http://app-server;
    }

    ssl on;
    ssl_certificate      /etc/nginx/server.crt;
    ssl_certificate_key  /etc/nginx/server.key;
    ssl_client_certificate /etc/nginx/server.crt;
    ssl_verify_client optional;
}
Run Code Online (Sandbox Code Playgroud)

nginx x509certificatevalidator

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

如何将请求从 nginx 和 React 容器发送到 Spring Boot 容器?

我有两个 Docker 容器,它们具有独立的应用程序前端和后端。

在第一个容器中,我已经构建了 ReactJS 代码和 nginx Web 服务器。这是 Dockerfile,

FROM nginx:1.15.2-alpine
COPY ./build /var/www
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
ENTRYPOINT ["nginx","-g","daemon off;"]
Run Code Online (Sandbox Code Playgroud)

这是我的 nginx.conf 文件,

worker_processes 1;
events {
    worker_connections 1024;
}

http {
    server_tokens off;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    upstream server {
        server 172.20.58.236:8080;
    }

    upstream client {
        server 172.19.59.36;
    }


    server {
        listen 80;

        root /var/www;
        index index.html index.htm;

        add_header 'Access-Control-Allow-Origin'  'http://172.19.59.36';
        add_header 'Access-Control-Allow_Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
        add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';


        location /api {
            proxy_pass http://server;
        } …
Run Code Online (Sandbox Code Playgroud)

nginx cors docker reactjs spring-boot

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

我的 Cors 预检选项请求似乎很慢

我注意到“cors”检查花费的时间比我预期的要长。本地主机、质量保证和生产以不同的速度发生这种情况。

我正在使用 axios (^0.18.0),它使用 mobx/MST/reactjs 和 asp.net core api 2.2

我可以设置范围从 20 毫秒到 10 秒的预检选项,并且它会随机变化。

例如我有

https://localhost:44391/api/Countries
Run Code Online (Sandbox Code Playgroud)

这是一个 get 请求,它可能需要 20 毫秒,连续 9 次(我 ctrl + F5),但在第 10 次它决定花费几秒钟(我在本地主机上没有真正得到秒,但有时是一秒钟)。

在此输入图像描述

因此,在这个测试中,204(cors 请求)需要 215 毫秒,而带回数据的实际请求只需要一半时间。这看起来倒退了。

在此输入图像描述

在此输入图像描述

这是我的ajax请求

 const axiosInstance = axios.create({
      baseURL: 'https://localhost:44391/api/Countries',
      timeout: 120000,
      headers: {
        contentType: 'application/json',
      }})

      axiosInstance.get();
Run Code Online (Sandbox Code Playgroud)

这是我的启动。我把cors全部打开,并想在解决这个问题后对其进行改进。

public class Startup
    {
        public IHostingEnvironment HostingEnvironment { get; }
        private readonly ILogger<Startup> logger;
        public Startup(IConfiguration configuration, IHostingEnvironment env, ILogger<Startup> logger)
        {
            Configuration = configuration;
            HostingEnvironment = env;
            this.logger = logger; …
Run Code Online (Sandbox Code Playgroud)

performance cors asp.net-core axios asp.net-core-2.0

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