Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

330
Vistas
What is the relationship of server's setting in both nginx.conf and proxy.conf?

I am very newbie on NGINX.

In my project, the server is defined in both etc/nginx/nginx.conf and etc/nginx/conf.d/proxy.conf. And etc/nginx/conf.d/proxy.conf is included in nginx.conf

I am not understand the relationship the server's setting in these two files. ex. In nginx.conf, server's setting is listen 80 ; listen [::]:80 ; and in proxy.conf, server's setting is listen 80 proxy_protocol.

  1. In above example, which setting will be used in real communication?
  2. Does the server's setting of proxy.conf overwrite the server's setting of nginx.conf?
  3. or the server's setting of proxy.conf will be merged into server's setting of nginx.conf?

Please find the full conf files as below:

etc/nginx/conf.d/proxy.conf

content: |
  client_max_body_size 500M;
  server_names_hash_bucket_size 128;

  upstream backend {
    server unix:///var/run/puma/my_app.sock;
  }

  server {
     listen 80 proxy_protocol;

     access_log /var/log/nginx/access.log;
     error_log /var/log/nginx/error.log;
  
     large_client_header_buffers 8 32k;

     set_real_ip_from 10.0.0.0/8;
     real_ip_header proxy_protocol;

    location / {
       proxy_http_version 1.1;
       proxy_set_header X-Real-IP $proxy_protocol_addr;
       proxy_set_header X-Forwarded-For $proxy_protocol_addr;
       proxy_set_header Host $http_host;
       proxy_set_header X-NginX-Proxy true;
       proxy_buffers 8 32k;
       proxy_buffer_size 64k;
       proxy_pass http://backend;
       proxy_redirect off;

       Enables WebSocket support
     location /v1/cable {
         proxy_pass http://backend;
         proxy_http_version 1.1;
         proxy_set_header Upgrade "websocket";
         proxy_set_header Connection "Upgrade";
         proxy_set_header X-Real-IP $proxy_protocol_addr;
         proxy_set_header X-Forwarded-For $proxy_protocol_addr;
      }
    }
  }

etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 ;
        listen       [::]:80 ;
        server_name  localhost;
        root         /usr/share/nginx/html;

        location / {
        }      
    }   
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Nginx selects a server block to process a request based on the values of the listen and server_name directives.

If a matching server name cannot be found, the default server for that port will be used.

In the configuration in your question, the server block in proxy.conf is encountered first, so it becomes the de-facto default server for port 80.

The server block in nginx.conf will only match requests which use the correct host name, i.e. http://localhost

See this document for details.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda