How to proxy web app with Nginx
1 min readJan 24, 2019
I have a CentOS
server which running Angular Web App
on port 4200
, and I want to access this web app with http://MY_SERVER
. What should I do?
1. Install Nginx
$ sudo yum install nginx
2. Start Nginx
$ sudo systemctl start nginx
3. Enable Nginx
$ sudo systemctl enable nginx
4. Add HTTP/HTTPS Firewall
$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --permanent --zone=public --add-service=https
$ sudo firewall-cmd --reload
5. Test Nginx
Open URL http://MY_SERVER
, and I should see Nginx Welcome Page
.
6. Add Proxy Pass to nginx.conf
server {
... listen 80 default_server; ... location / { proxy_pass http://127.0.0.1:4200; }
...
}
7. Restart Nginx
$ systemctl restart nginx
8. Test Proxy
Open URL http://MY_SERVER
, and I should see my Angular Web App
Reference: https://nginx.org/en/docs/