Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!