1

I have a headless proxy multisite setup locally using JSS. I have two sites, SiteA and SiteB. I'm using vhost in node to serve as a middleware to resolve the hostname.

http://expressjs.com/en/resources/middleware/vhost.html

This is my server.js that works locally.

// For any other requests, we render app routes server-side and return them

const siteAUrl = 'sitea.com';
const siteBUrl = 'siteb.com';


// site a
const siteA = express();
const siteAConfig = getConfig('sitea');
siteA.use('*', scProxy(siteAConfig.serverBundle.renderView, siteAConfig, siteAConfig.serverBundle.parseRouteUrl));
server.use(vhost(siteAUrl, siteA));

// site b
const siteB = express();
const siteBUrl = getConfig('siteb');
siteB.use('*', scProxy(siteBUrl.serverBundle.renderView, siteBUrl, siteBUrl.serverBundle.parseRouteUrl));
server.use(vhost(siteBUrl, siteB));


server.listen(port, function () {
  console.log('server listening on port: ', port);
});

server.keepAliveTimeout = 30 * 1000;

server.on('connection', function (socket) {
  socket.setTimeout(30 * 1000); // 30 second timeout
});

Once this app is deployed to an azure app service it is erroring and giving 500 errors. I have checked all the logs and I'm not receiving any info telling me why I'm getting 500 errors just the generic IIS 500 Internal Server Error HTML printed in the console.

I think I have narrowed the error down to using vhost. When I remove the use of vhost it works.

server.use('*', scProxy(config.serverBundle.renderView, config, config.serverBundle.parseRouteUrl));

but I lose my multisite functionality with this.

Do I need to do anything additional on azure to enable using vhost on the app service or can I use something similar to vhost to achieve the same thing?

Thank you!

Sitecore Version: 9.2 JSS

1

1 Answer 1

0

The reason vhost wasn't working for me is because our sitecore implementation is behind a reverse proxy. Vhost doesn't support being behind a reverse proxy at the moment.

Github vhost issue

With a simple modification to the package, you can modify vhost to support reverse proxies.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.