universal-vue / uvue

Vue CLI plugin to create universal Vue applications with ease
https://universal-vue.github.io/docs/
MIT License
127 stars 13 forks source link

Integrate with nginx unit #8

Open academici opened 5 years ago

academici commented 5 years ago

Nginx Unit from the version 1.5 supports nodejs applications (http://unit.nginx.org/configuration/#go-node-js-applications)

To start, you need to write a script like

#!/usr/bin/env node

const {
  createServer,
  IncomingMessage,
  ServerResponse,
} = require('unit-http')

require('http').ServerResponse = ServerResponse
require('http').IncomingMessage = IncomingMessage

const express = require('express')

const app = express()

app.get('/', (req, res) => {
  res.set('X-Unit-Type', 'Absolute')
  res.send('Hello, Unit!')
})

createServer(app).listen()

and integrate with uvue server adapters https://universal-vue.github.io/docs/guide/server.html#adapters

...combined with this configuration...

{
  "listeners": {
    "*:8080": {
      "application": "hello-unit"
    }
  },
  "applications": {
    "hello-unit": {
      "type": "external",
      "working_directory": "/path/to/project",
      "executable": "app.js"
    }
  }
}