I have one PHP app running on localhost port 80 and another running on port 81.
Pointing the browser to http://localhost
runs the first app and all of its assets: js, css, imgs in the /assets
folder. However, the 2nd app only can serve assets that have the exact file name as the 1st app. If the 2nd app's assets are in the 2nd app's /assets
directory and don't have the same name as files in the first apps /assets
folder, then those files aren't found an you get a 404
error.
Here's more specifics on what I'm seeing:
http://localhost
<script src='/assets/foo.js'></script>
//file contents
alert('foo'); when foo.js is in app #1's /assets directory
http://localhost:81
<script src='/assets/foo.js'></script>
alert('foo 2'); //alerts "foo 2" when foo.js is in app #2's /assets directory
<script src='/assets/bar.js'></script>
//file contents:
alert('bar'); //file not found 404 error when bar.js is in app #2's /assets directory
The likely cause of the problem in my nginx.conf
:
http {
include /Applications/MNPP/conf/nginx/sites-enabled/app2;
include /Applications/MNPP/conf/nginx/sites-enabled/app1;
...
/Applications/MNPP/conf/nginx/sites-enabled/app2:
server {
listen 81;
server_name localhost:81;
...
/Applications/MNPP/conf/nginx/sites-enabled/app1:
server {
listen 80;
server_name localhost;
...