编译安装
- Nginx下载地址: http://nginx.org/en/download.html
- 编译安装:
1
2
3./configure --with-http_stub_status_module --with-http_ssl_module
make
make install
Nginx启动
启动:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx.conf配置:
1
2
3
4
5
6
7
8
9
10
11server {
listen 8080; //监听的端口
server_name localhost; //监听的ip地址
location / { //匹配所有请求
root /opt/dist; //前端
}
location /api {
proxy_pass http://192.16.18.111:9999; //后端
rewrite "^/api/(.*)$" /$1 break;
}
}