I use a Vagrant VM to reproduce my production server for local web development.
Host machine is running Windows 10 and guest runs Nginx 1.10 on Ubuntu 14.04 with VirtualBox as a provider.
I want to serve files during development using Gulp and Browsersync. Here is my browsersync configuration from gulp serve task:
browserSync.init({
ui: {
port: 3001
},
open: false,
port: 3000,
server: {
baseDir: ['.tmp', 'app'],
routes: {
"/bower_components": "bower_components"
}
}
});
I managed to get it to work with this:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
server_name test.local.dev;
location / {
proxy_pass http://localhost:3000/;
}
location /ui/ {
proxy_pass http://localhost:3001/;
}
# BrowserSync websocket
location /browser-sync/socket.io/ {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
Socket configuration as seen here: How to make BrowserSync work with an nginx proxy server?
The site, reloads and browsersyncing works great. But UI can't find needed files.
GET http://test.local.dev/js/vendor/socket.js
GET http://test.local.dev/js/app.min.js
GET http://test.local.dev/js/pages-config.js
GET http://test.local.dev/lib/client-js.js
GET http://test.local.dev/js/vendor/socket.js
GET http://test.local.dev/js/app.min.js
GET http://test.local.dev/js/pages-config.js
GET http://test.local.dev/lib/client-js.js 404 (Not Found)
How can I set up routes for those requests in Browsersync configuration? If it's impossible is there any way to make it work?