Skip to content

Commit

Permalink
Fixed paths in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel LaBarge committed Mar 5, 2017
1 parent b6d8053 commit 3f3d3fc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
54 changes: 51 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
# Larandomizer

The Laravel application that you install and deploy that includes all necessary
ReactPHP components as dependencies.
Larandomizer is a websocket server application written with Laravel and React PHP
to give away prizes at meetups and conferences and to teach async in PHP. This
repository is the Laravel application that you install and deploy. It includes
all the necessary ReactPHP components as dependencies.

## Nginx Configuration
## Installation

The application installs like any Laravel application. The following shows one
possible way to install the application. While Composer is required, Yarn is
optional and you could just as easily use NPM instead.

```
mkdir larandomizer
cd larandomizer
git clone https://github.com/larandomizer/app ./
composer install
yarn install
npm run production
cp .env.example .env
php artisan key:generate
```

You will still want to edit the `.env` file to customize environment settings.
No database is used as all data is stored in memory on the server.

### Nginx Websocket Proxy Configuration

Nginx makes the perfect lightweight frontend server for the Laravel backend
application. Additionally it can be used to proxy websockets connecting on port
`80` to the `8080` default server socket. Doing so helps get around some firewall
settings. The following should be placed just before your default `location`
directive for the Laravel application itself (e.g.: Forge's default). Using these
settings you can host websockets securely with the `wss://` protocol allowing
Nginx to handle the SSL connection and your websocket server handling basic HTTP.

```
location /socket/ {
Expand All @@ -17,3 +47,21 @@ location /socket/ {
proxy_set_header Connection "upgrade";
}
```

A quick note on the settings used:

- `location /socket/` directs all traffic going to `/socket/` to the proxy
- `proxy_pass` passes the traffic to the localhost webserver on port `8080`
- `proxy_read_timeout` customizes the connection drop to hang up idle connections
- `proxy_http_version` is the version of the websocket protocol in HTTP
- `X-Real-IP` header gives your websocket server the real IP of the client connection
- `Upgrade` and `Connection` headers instruct the browser to upgrade to websocket connection

### Starting the Server

The websocket server can be ran as an console command using `php artisan server:start`
and if you pass `--help` to the command you can see additional options. You can
stop the running server by killing the process with `CMD + C` (or `CTRL + C`).

In production you would want to have Supervisor monitor the server and restart
it if ever it crashes.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"private": true,
"scripts": {
"dev": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/cross-env/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
"dev": "node node_modules/.bin/cross-env NODE_ENV=development node_modules/.bin/webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/.bin/cross-env NODE_ENV=development node_modules/.bin/webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/.bin/cross-env NODE_ENV=development node_modules/.bin/webpack --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/.bin/cross-env NODE_ENV=development node_modules/.bin/webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/.bin/cross-env NODE_ENV=production node_modules/.bin/webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"dependencies": {
"axios": "^0.15.3",
Expand Down
4 changes: 0 additions & 4 deletions public/mix-manifest.json

This file was deleted.

0 comments on commit 3f3d3fc

Please sign in to comment.