# Regarding gRPC with NGINX

**URL:** <https://community.nginx.org/t/regarding-grpc-with-nginx/2224>\
**Category:** NGINX\
**Tags:** grpc\
**Created:** [April 17, 2025, 4:57am UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224 "2025-04-17T04:57:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohan\_bindal](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/rohan_bindal/32/1317_2.png) [@rohan\_bindal](https://community.nginx.org/u/rohan_bindal)\
**Post date:** [April 17, 2025, 4:57am UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224/1 "2025-04-17T04:57:25Z")

</div>

I want to use grpc with nginx in which I need to assign TCP calls and grpc calls to the same subdomain can anyone help me regarding this

---

<div class="post-metadata">

**Author:** ![liam](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/liam/32/99_2.png) [@liam](https://community.nginx.org/u/liam)\
**Post date:** [April 17, 2025, 9:26am UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224/2 "2025-04-17T09:26:18Z")

</div>

So long as you intend to use different ports for the TCP traffic and the gRPC traffic then it’s simply a case of creating a stream{} configuration for TCP and a http{} configuration for gRPC. Both can refer to the same `ssl_certificate` files on disk for the same subdomain.

---

<div class="post-metadata">

**Author:** ![rohan\_bindal](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/rohan_bindal/32/1317_2.png) [@rohan\_bindal](https://community.nginx.org/u/rohan_bindal)\
**Post date:** [April 17, 2025, 10:00am UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224/3 "2025-04-17T10:00:43Z")

</div>

I am receiving 404 error from nginx while calling grpc method.

 ![17448839922757902421359845344100](https://d7a5pgbt9tjl6.cloudfront.net/original/2X/d/d00f42cea5bd9456a3d20e8b851d06357176a803.jpeg)

---

<div class="post-metadata">

**Author:** ![rohan\_bindal](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/rohan_bindal/32/1317_2.png) [@rohan\_bindal](https://community.nginx.org/u/rohan_bindal)\
**Post date:** [April 17, 2025, 10:03am UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224/4 "2025-04-17T10:03:11Z")

</div>

My config for nginx are as below:

server {  
server\_name [test.xyz.com](http://test.xyz.com);  
listen 80;  
listen [::]:80;  
return 301 https://$host$request\_uri;  
}

# HTTPS server block

server {  
server\_name devexpertapi.fairgame.club;

```
# Enable HTTP/2 and HTTP/3
listen 443 ssl;
listen [::]:443 ssl;
listen 443 quic;
listen [::]:443 quic;

# SSL Configuration
ssl_certificate /etc/letsencrypt/live/devexpertapi.fairgame.club/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/devexpertapi.fairgame.club/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

```

# ========== gRPC Proxy ==========

```
location /grpc {
    rewrite ^/grpc/(.*)$ /$1 break;
    grpc_pass grpcs://localhost:60601;
    error_page 502 = /error502grpc;
    # grpc_pass localhost:60601;

    grpc_set_header Host $host;
    grpc_set_header X-Real-IP $remote_addr;
    grpc_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    grpc_set_header X-Forwarded-Proto $scheme;

    grpc_read_timeout 300s;
    grpc_send_timeout 300s;
}

location = /error502grpc {
    internal;
    default_type application/grpc;
    add_header grpc-status 14;
    add_header grpc-message "unavailable";
    return 204;
}

# Proxy to local service
location / {
    proxy_pass https://localhost:6060;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    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;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-Server $host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off;
}

# Security headers
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

# HTTP/3 advertisement
add_header Alt-Svc 'h3=":443"; ma=86400, h3-29=":443"; ma=86400';

# Optional: Uncomment if you're using FastCGI caching
# add_header X-FastCGI-Cache $upstream_cache_status;

# Remove or comment out these non-standard headers
# add_header QUIC-Status $http3;
# add_header x-quic 'h3';
# add_header X-protocol $server_protocol always;

```

}

---

<div class="post-metadata">

**Author:** ![alessandro](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/alessandro/32/4836_2.png) [@alessandro](https://community.nginx.org/u/alessandro)\
**Post date:** [July 19, 2025, 1:13pm UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224/5 "2025-07-19T13:13:13Z")

</div>

Heya! The first thing that comes to mind when seeing your config is that you are querying NGINX on port 443, yet `gRPC` is only enabled on the `/grpc` location on the server block that’s listening on `443`. On your default location `/`, you are proxy passing to something listening on port 6060 in your localhost and it’s not being done via `gRPC`. What is supposed to be listening on port 6060?

Beyond that, I would suggest trying to query the `/grpc` location instead of `/`, or alternatively moving the contents inside the default `/` location to a different port (like @liam suggested above) and renaming the `/grpc` location to `/`.

---

<div class="post-metadata">

**Author:** ![system](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/system/32/19_2.png) [@system](https://community.nginx.org/u/system)\
**Post date:** [August 18, 2025, 1:13pm UTC](https://community.nginx.org/t/regarding-grpc-with-nginx/2224/6 "2025-08-18T13:13:41Z")

</div>

Closed on August 18, 2025, 1:13pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
