Commit 33df3db4 authored by Patricio Bruna's avatar Patricio Bruna

Merge pull request #40 from ZBoxApp/nginx

Add nginx config example and update README
parents 62029691 e41b1127
...@@ -27,7 +27,7 @@ The is a configuration file under `config/config.json` with the following struct ...@@ -27,7 +27,7 @@ The is a configuration file under `config/config.json` with the following struct
* **debug**: Use in development environmet to recieve messages in the javascript console. * **debug**: Use in development environmet to recieve messages in the javascript console.
* **zimbraUrl**: The URL where the zimbra admin services are running. * **zimbraUrl**: The URL where the zimbra admin services are running.
* **zimbraProxy**: The URL of a proxy server to allow CORS between the webapp and the Zimbra admin service. * **zimbraProxy**: The URL of a proxy server to allow CORS between the webapp and the Zimbra admin service. (Only needed in **development** environment for the server)
* **dnsApiUrl**: URL of the DNS api to get DNS information ( [zDNS](https://github.com/ZBoxApp/zDNS) ). * **dnsApiUrl**: URL of the DNS api to get DNS information ( [zDNS](https://github.com/ZBoxApp/zDNS) ).
* **plans**: Object with the available mailboxes plans, set to *true* if enabled or *false* to disable it. * **plans**: Object with the available mailboxes plans, set to *true* if enabled or *false* to disable it.
* **companiesEndPoints**: This are the enpoints to get information about companies and invoices. (Checkout the companies endpoint specifications below). * **companiesEndPoints**: This are the enpoints to get information about companies and invoices. (Checkout the companies endpoint specifications below).
...@@ -99,6 +99,20 @@ Posible status are: ...@@ -99,6 +99,20 @@ Posible status are:
| 2 | Vencida | | 2 | Vencida |
| 3 | Anulada | | 3 | Anulada |
## Deployment
You'll need to build the sources ready for production by running
```
$ make build
```
This will generate a folder called `dist` which holds all the necessary files for deploying the website.
This files have to be copied to your server running `NGINX`.
Copy the files to `NGINX` html folder and you're done.
A sample for the `NGINX` configuration can be found [here](nginx/nginx.conf).
## TODO ## TODO
* Add security to the companies Endpoints * Add security to the companies Endpoints
#user nobody;
#Defines which Linux system user will own and run the Nginx server
worker_processes 1;
#Referes to single threaded process. Generally set to be equal to the number of CPUs or cores.
#error_log logs/error.log; #error_log logs/error.log notice;
#Specifies the file where server logs.
#pid logs/nginx.pid;
#nginx will write its master process ID(PID).
events {
worker_connections 1024;
# worker_processes and worker_connections allows you to calculate maxclients value:
# max_clients = worker_processes * worker_connections
}
http {
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile off;
# If serving locally stored static files, sendfile is essential to speed up the server,
# But if using as reverse proxy one can deactivate it
#tcp_nopush on;
# works opposite to tcp_nodelay. Instead of optimizing delays, it optimizes the amount of data sent at once.
#keepalive_timeout 0;
keepalive_timeout 65;
# timeout during which a keep-alive client connection will stay open.
#gzip on;
# tells the server to use on-the-fly gzip compression.
server {
# You would want to make a separate file with its own server block for each virtual domain
# on your server and then include them.
listen 80;
#tells Nginx the hostname and the TCP port where it should listen for HTTP connections.
# listen 80; is equivalent to listen *:80;
server_name localhost;
# lets you doname-based virtual hosting
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#The location setting lets you configure how nginx responds to requests for resources within the server.
root /html;
index index.html index.htm;
try_files $uri /index.html;
}
#error_page 404 /404.html;
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 8001;
# server_name somename alias another.alias;
location /service/admin/soap {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://192.168.50.10:7071/service/admin/soap;
}
}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
}, },
"scripts": { "scripts": {
"check": "eslint --ext \".jsx\" --ignore-pattern node_modules --quiet .", "check": "eslint --ext \".jsx\" --ignore-pattern node_modules --quiet .",
"build": "webpack", "build": "NODE_ENV=production webpack",
"run": "webpack --progress --watch", "run": "webpack --progress --watch",
"run-fullmap": "webpack --progress --watch", "run-fullmap": "webpack --progress --watch",
"companies-service": "babel-node companies-service.js", "companies-service": "babel-node companies-service.js",
......
...@@ -125,6 +125,13 @@ if (!DEV) { ...@@ -125,6 +125,13 @@ if (!DEV) {
config.plugins.push( config.plugins.push(
new webpack.optimize.DedupePlugin() new webpack.optimize.DedupePlugin()
); );
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
})
);
} }
module.exports = config; module.exports = config;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment