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

124
Vistas
Nginx serving static files from wrong application on http. It works correctly on https

I have 2 instances of the same applications working on 2 tomcats. Lets say that thay are accessible on xyz1.domain.com and xyz2.domain.com with a use of nginx. I have access to the files of xyz1 application over http and https without any problems. The same goes for https access of xyz2 application. But when i'm trying to get files of xyz2 application over http i'm getting xyz1 files instead. And i need to access them over http... The configs are as below:

xyz1.conf

server {
    listen 443 ssl;

    server_name xyz1.domain.com www.xyz1.domain.com;

    ssl on;
    ssl_certificate /home/ubuntu/xyz1/path/fullchain.pem;
    ssl_certificate_key /home/ubuntu/xyz1/path/privkey.pem;

    root /home/ubuntu/xyz;
    error_page 502 503 504 /index-off.html;

    proxy_redirect off;
    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 Host $host;

    location /index-off.html{
    }

    location /demo {
        proxy_pass http://127.0.0.1:8180/demo;
    }


    location / {
        proxy_pass http://127.0.0.1:8080;
    }

}

server {
    listen 80;

    server_name xyz1.domain.com www.xyz1.domain.com;

    location /demo {
        return 301 https://xyz1.domain.com$request_uri;
    }

    location / {
        return 301 https://xyz1.domain.com$request_uri;
    }
}

xyz2.conf

server {
    listen 443 ssl;

    server_name xyz2.domain.com www.xyz2.domain.com;

    ssl on;
    ssl_certificate /home/ubuntu/xyz1/path/fullchain.pem;
    ssl_certificate_key /home/ubuntu/xyz1/path/privkey.pem;

    root /home/ubuntu/xyz2/xyz;
    error_page 502 503 504 /index-off.html;

    proxy_redirect off;
    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 Host $host;

        location /index-off.html{
        }

    location / {
        proxy_pass http://127.0.0.1:8280/;
    }

}

server {
    listen 80;

    server_name xyz2.domain.com www.xyz2.domain.com;

    root /home/ubuntu/xyz2/xyz;

    location / {
        proxy_pass http://127.0.0.1:8280/;
#                root /home/ubuntu/xyz2/xyz;
    }

}

I've tried different combinations of root settings for xyz2, both for whole server config, and location setting. I'he even tried to create specific location like /unique/path/ with root like /home/ubuntu/xyz2/xyz/unique/path with only 1 file instide. And i still couldn't get that file. The same thing happens when xyz1 application config is off (out of sites-enabled). Http on xyz2 serves files from xyz1 directory... I have no more ideas on how to approach it. It looks as if xyz2 http config is ignored... I scanned whole nginx directory for both applications paths, and there was no crossconfig between them.

Any ideas of what could i change to make xyz2 application files accessible over http?

over 4 years ago · Santiago Trujillo
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