Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda