nginx returning 404 for resources requested via proxy_pass, but not root document

I have a problem with nginx proxy_pass not passing asset requests [css, js, fonts, etc] to the upstream server. Details about my configuration are below.

I have the following configuration for nginx on my application server set up:


upstream webapp {
    server 127.0.0.1:10000;
}


server {
    server_name wma.xxxxx.io;
    include includes/_general.conf;

    location / {

       access_log /var/log/nginx/webapp/access.log upstream_logging;
       error_log  /var/log/nginx/webapp/error.log warn;

       proxy_pass http://webapp/;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-Proto $scheme;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#      proxy_redirect http://$host:10000 https://$http_host;
       #index index.html;
    }

    listen 5555;

}

Now, when I navigate to the url http://wma.xxxxx.io, the page /loads/ – but none of the resources associated with it, do. So, no css, no js files, etc.

When I request a document from the server that is behind the proxy, it works:

root@appserver [/etc/nginx/sites-enabled] # curl -I http://localhost:10000/service-worker.js
HTTP/1.0 200 Document follows
Date: Fri, 9 Aug 2024 05:54:45 GMT
Server: MiniServ
Content-type: application/javascript
Last-Modified: Wed, 24 Jul 2024 04:58:46 GMT
Expires: Fri, 16 Aug 2024 05:54:45 GMT
Cache-Control: public; max-age=604800
Content-length: 94
Connection: close

However, performing the same request to the nginx proxy:

root@appserver [/etc/nginx/sites-enabled] # curl -I http://localhost:5555/service-worker.js
HTTP/1.1 404 Not Found
Server: nginx/1.20.1
Date: Fri, 09 Aug 2024 05:54:39 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 153
Connection: keep-alive
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer-when-downgrade
Content-Security-Policy: default-src * data: 'unsafe-eval' 'unsafe-inline'

We get that 404 error. This error occurs for all resources: fonts, css, images, javascript, and so forth.

The _general.conf file contains the following:

#set_real_ip_from 10.2.46.0/24;
#real_ip_header proxy_protocol;

add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;

# . files

#location /.well-known/acme-challenge/ {
#       try_files $uri /dev/null =404;
#}

location ~ /. {
        deny all;
}

# assets, media
location ~* .(?:css(.map)?|js(.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
        expires 7d;
        access_log off;
}

# svg, fonts
location ~* .(?:svgz?|ttf|ttc|otf|eot|woff|woff2)$ {
        add_header Access-Control-Allow-Origin "*";
        expires 7d;
        access_log off;
}

# gzip rules
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;

I am stumped – it seems as though nginx is looking for the assets locally instead of proxy_passing them to the upstream server. If that is the case, how do I make it pass all the requests to the upstream server?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật