Learn about Centmin Mod LEMP Stack today
Register Now

Nginx Nginx Forwarding Images to local dir instead of tomcat

Discussion in 'Install & Upgrades or Pre-Install Questions' started by ninjasenses, Mar 11, 2019.

  1. ninjasenses

    ninjasenses New Member

    4
    0
    1
    Mar 4, 2019
    Ratings:
    +1
    Local Time:
    5:34 AM
    • CentOS Version: CentOS 7 64bit ?
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.15.9
    • PHP Version Installed: 7.3
    • MariaDB MySQL Version Installed: mysqld 10.1.38-MariaDB
    • When was last time updated Centmin Mod code base ? : today
    • Persistent Config: N

    I have a spring boot app that is running on tomcat. All of my endpoints and controllers work except for onethat handles images ex: {{url}}/media/1.jpg. Whenever I request the image, the request fails out in nginx before it even makes it to the tomcat controller:

    2019/03/10 19:56:55 [error] 11456#11456: *2 open() "/usr/local/nginx/html/media/1.jpg" failed (2: No such file or directory), client: 143.59.116.175, server: my.server.com, request: "GET /media/1.jpg HTTP/1.1", host: "my.server.com"

    I havent setup any custom nginx config besides the ones below which acts as proxy for tomcat. It seems that centmin mod has some sort of config already in place for images. Does anyone know what is going on here?



    Code:
    server {
                listen 80 default_server backlog=2048 reuseport;
                #server_name _;
                server_name my.server.com;
                #root   html;
    
    
            access_log              /var/log/nginx/localhost.access.log     combined buffer=256k flush=5m;
            error_log               /var/log/nginx/localhost.error.log      error;
    
        proxy_redirect           off;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
    # limit_conn limit_per_ip 16;
    # ssi  on;
    
            location /nginx_status {
            stub_status on;
            access_log   off;
            allow 127.0.0.1;
            #allow youripaddress;
            deny all;
            }
    
                location / {
    
                            proxy_pass http://127.0.0.1:8080;
                            proxy_set_header         X-Real-IP $remote_addr;
                            proxy_set_header         X-Forwarded-For $proxy_add_x_forwarded_for;
                            proxy_set_header         Host $http_host;
    
                            # block common exploits, sql injections etc
                            #include /usr/local/nginx/conf/block.conf;
    
                            # Wordpress Permalinks example
                            #try_files \$uri \$uri/ /index.php?q=\$uri&\$args;
    
                }
    
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/include_opcache.conf;
    include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/phpstatus.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    #include /usr/local/nginx/conf/vts_mainserver.conf;
    
           }
     
  2. ninjasenses

    ninjasenses New Member

    4
    0
    1
    Mar 4, 2019
    Ratings:
    +1
    Local Time:
    5:34 AM
    I had to comment out :

    Code:
    include /usr/local/nginx/conf/staticfiles.conf;
    
    in order to fix this issue
     
    • Informative Informative x 1
  3. eva2000

    eva2000 Administrator Staff Member

    41,316
    9,274
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,229
    Local Time:
    7:34 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yes the staticfiles.conf handles static images/files but can interfere for some web apps.