Use a list of CIDR for trusted-proxies

Aperta
#4,371 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@vasipallyn ci sta già lavorando.

Dal 13/11/2026.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java, spring-boot

Direzione di ricerca

Start by finding where spring.cloud.gateway.server.webmvc.trusted-proxies is bound and where its regular expression is matched against the remote address, using a search for the property name. The issue asks for a list of IP addresses and CIDR ranges, including IPv6 such as ::1/128, in place of the regex. Done means the YAML example in the issue is accepted and matched correctly, with tests covering IPv4, IPv6 and non-matching addresses. Whether the regex form stays supported is a design question to confirm with maintainers.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

waiting-for-triage

Is your feature request related to a problem? Please describe.

The spring.cloud.gateway.server.webmvc.trusted-proxies property currently uses a regular expression to identify trusted proxies.

However, getRemoteAddr() already returns the IP address of the client or the last proxy that sent the request:

/**
 * Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. For HTTP servlets,
 * same as the value of the CGI variable <code>REMOTE_ADDR</code>.
 *
 * @return a <code>String</code> containing the IP address of the client that sent the request
 */

Since this property is intended to identify trusted proxies based on their IP addresses, using regular expressions seems unnecessarily complex and makes the configuration harder to maintain.

Describe the solution you'd like

Replace the regular expression with a list of IP addresses and CIDR ranges.

For example:

spring:
  cloud:
    gateway:
      server:
        webmvc:
          trusted-proxies:
            - 10.0.0.0/8
            - 172.16.0.0/12
            - 192.168.0.0/16
            - 127.0.0.1/32
            - ::1/128
Lingua principale
Java
Stelle
4.9k
Fork
3.5k
Merge medio
1g 13h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di spring-cloud/spring-cloud-gateway

Tutte le issue di spring-cloud/spring-cloud-gateway

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.