Opensearch API Reverse Proxy Nginx

Hello, I have installed OpenSearch on a virtual machine. My NGINX configuration is as below. I can access the dashboard via FQDN, but I can’t access the API. I can only access the API using the IP:Port format, and I couldn’t understand why. Does anyone know the solution?
my network.host is 0.0.0.0

    location / {
        proxy_pass http://localhost:5601;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto \$scheme;
    }

    # OpenSearch Proxy
    location /backend/ {
        proxy_pass http://localhost:9200;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto \$scheme;
    }

@bastus11 This configuration worked for me.

        location / {
            proxy_pass https://docker1.pablo.local:5601/;
            proxy_ssl_verify off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        # OpenSearch Proxy (HTTPS Backend)
        location /backend/ {
            proxy_pass https://docker1.pablo.local:9200/;
            proxy_ssl_verify off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

Try adding trailing slash in both OpenSearch and OpenSearch Dashboards

1 Like