Relative path return 404 on ubuntu

sfarzoso asked:

I developed a small nodejs application and I’m facing a weird issue.
Essentially, I’m using ExpressJS and I configured the static files, such as (js, css, etc…) to that path:

app.use(express.static(path.join(__dirname, "../public")));

when I run the application on windows I have no problem, all the css and js file are loaded correctly, eg:

<!-- STYLE CSS -->
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/custom-style.css">

but when I run the app on ubuntu I get the 404 error.

The structure of the app is:

app.js
     config
          environment.js
     public 
          css
          js

the file environment.js load the folder public.

Perhaps the problem is in my Apache Proxy:

<VirtualHost *:80>

    ServerAdmin [email protected]
    ServerName mydomain.com
    ServerAlias *.mydomain.com
    DocumentRoot /var/www/html/mysite.com
    ProxyPass /calc/ http://localhost:4568/
    ProxyPassReverse /calc/ http://localhost:4568

infact I entered with VNC and if I type: localhost:4568 works, the problem happen when I use mydomain.com/calc, the app loading but the statics file not..

My answer:


AFAIK the DocumentRoot is supposed to be set to the top-level directory containing your static files, i.e. the public directory. So it should be closer to:

DocumentRoot /var/www/html/example.com/public

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.