Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
717 views
in Technique[技术] by (71.8m points)

proxy - Can we can configure grpc_pass and proxy_pass on single nginx conf for the same location(/)?

I am trying to configure Percona PMM along with my proxy servers so that my client servers can securely connect to PMM server. Attaching the current setup here.

Also providing the nginx conf I am using now.

server {
listen 443 ssl http2;

server_name proxy_domain.com;

ssl_certificate /etc/nginx/certificates/certificate.crt;
ssl_certificate_key /etc/nginx/certificates/certificate.key;



location / {

grpc_pass grpcs://PMM_serverIP:443;


}

}

I can't access the grfana which should be work when I call proxy_domain.com(but now it is redirecting to PMM_serverIP:443) as per the above nginx conf.

I use port 9116 for accessing the grafana by using an additional conf that is given below.

server {
    listen 9116 ssl http2;

    server_name proxy_domain.com;

    ssl_certificate /etc/nginx/certificates/certificate.crt;
    ssl_certificate_key /etc/nginx/certificates/certificate.key;
    ssl_session_cache shared:SSL:10m;

    ssl on;
    ssl_session_cache builtin:1000 shared:SSL:10m;
    ssl_protocols TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;
    
    location / {
    proxy_pass https://PMM_serverIP:443/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forward-Proto http;
    proxy_set_header X-Nginx-Proxy true;
    proxy_redirect off;
    }

    }

Can I use grpc_pass and proxy_pass for location " / " ? I tried but I can't do that. Also, I tried adding separate configs for grpc_pass and proxy_pass but the server_name conflicts. I want a secure connection using my certs. I also tried grpc_certificate for securing grpc. But still, it is just redirecting to the PMM server IP.

question from:https://stackoverflow.com/questions/65896892/can-we-can-configure-grpc-pass-and-proxy-pass-on-single-nginx-conf-for-the-same

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...