Serve Angular 6 App with nginx
The easiest fastest way to start a demo environment when you have a CentOs vm somewhere inside the organisation domain which is just for your use and you’re too lazy to compose a docker image or to use docker due to security limitations..
Prerequisites:
- install nginx
- install github
- checkout your project somewhere — I created a user
- Build the project to production as follows:
ng build --prod --base-href http://local-machine-ip/2. Configure the nginx.conf server as follows:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /home/demo/ensilo-cloud-frontend/dist/ensilo-cloud-frontend;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
3. Restart nginx: sudo systemctl restart nginx
BOOM that’s all :)
