Score:0

Running Opensearch behind a proxy

uz flag

when I configure nginx to redirect /monitor to opensearch, opensearch receives the requests and redirects the user to /app/something which is not under /monitor and thus fails (error 404).

My nginx config is

upstream opensearch {
    server 172.20.0.3:5601;
}

server {
    listen 443 ssl;
    server_name maindomain;
    server_tokens off;
    #access_log off;
    error_log  /var/log/nginx/cii.error_log  debug;
    access_log  /var/log/nginx/cii.error_log;


    ssl_certificate /etc/letsencrypt/live/mydomain/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mydomain/privkey.pem;

    include /var/ssl/options-ssl-nginx.conf;
    ssl_dhparam /var/ssl/dhparam.pem;

    
    location ~ ^/monitor(/?)(.*) {
        

        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_pass_header User-Agent;
        proxy_pass http://opensearch/$2;
    }
    #put the / location AT THE END
    location / {
        root /usr/share/nginx/html;
    }    
}

Any ideas how I can configure nginx (or Opensearch?) to continue using /monitor/app/something ?

djdomi avatar
za flag
Does this answer your question? [Nginx reverse proxy + URL rewrite](https://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite)
mojovski avatar
uz flag
thanks. I don't think so. My problem is not that I can't access the opensearch upstream. The problem is that when opensearch redirects to /app, it should be /monitor/app. I guess I will have to code all the cases (app, ...) as location inside the nginx config for rewrite then
djdomi avatar
za flag
each other path has to be set separate, nginx looks from top to down to find the right path inside the configuration
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.