Nginx возвращает '403 запрещено' для Java вызова API POST - самоподписанный CA - PullRequest
0 голосов
/ 29 мая 2020

Я бегаю по кругу с этим:

У меня есть сервер nginx (работающий на Redhat 7.8), который используется как обратный прокси для моего Java backe-end. Вызовы GET спереди назад работают нормально, но когда я пытаюсь выполнить POST, передняя часть получает 403 запрещено. Я предполагаю, что это из-за моего OpenSSL CA, которому не доверяют. Я пробовал разные вещи (например, followin this ), но ничего не работает. Я всегда получаю один и тот же результат:

openssl s_client -connect [server]:8083 -showcerts -CApath /etc/pki/tls/certs

Возвращает:

Verify return code: 19 (self signed certificate in certificate chain)

Когда я затем проверяю свой магазин CA с помощью этой команды:

/etc/pki/tls/certs

Я нахожу свой там самоподписанный CA (ca.crt), который имеет только один уровень, CA.

Однако, когда я пытаюсь проверить этот CA, я получаю:

openssl verify -CApath /etc/pki/tls/certs ca.crt

enter code hereca.crt: C = BE, ST = [location], L = [location], O = [company] 
error 18 at 0 depth lookup:self signed certificate
OK

Но я не понимаю почему? Вся суть наличия ЦС в хранилище ЦС состоит в том, чтобы распознать его, так что еще нужно сделать, чтобы ЦС распознал?

Я борюсь с этим уже несколько дней.

PS: для полноты картины, вот конфигурация моего nginx обратного прокси:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

#user nginx webusers;
worker_processes auto;
error_log /var/log/nginx/error.log debug;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

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;
    client_max_body_size 8M;
    # proxy_buffering     off;
    sendfile            on;
    # tcp_nopush          on;
    # tcp_nodelay         on;
    keepalive_timeout   65;
    # 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;

    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    server {
        listen 80 default; 
        server_name _;
        return 301 https://$host$request_uri;
    }

    server {
        listen       443 ssl;
        listen       8083 ssl;
        # Disable ipv6
        # listen       [::]:80 default_server;
fi        server_name  localhost;
        root         /usr/share/nginx/html;
        ssl_password_file /etc/nginx/pass/global.pass;
        ssl_protocols TLSv1.1 TLSv1.2; 
        ssl_certificate_key /etc/nginx/certs/user.key;
    ssl_certificate /etc/nginx/certs/user.crt;

        # client certificate
        ssl_client_certificate /etc/nginx/certs/ca.crt;
        # make verification optional, so we can display a 403 message to those
        # who fail authentication
        ssl_verify_client optional;

    # Load configuration files for the default server block.
        # include /etc/nginx/default.d/*.conf;

        location ~ ^/(api|login|logout) {
            proxy_pass http://localhost:8080;
            proxy_set_header Connection "";
        }

        location /ws {
            proxy_pass http://127.0.0.1:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }

        location / {
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $http_host;
        try_files $uri $uri/ $uri.html /index.html;
    }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...