首页 » ngnix » 正文

Mac上安装nginx和连接到tomcat

1. 安装pcre

sudo brew install pcre

2. 配置

./configure –prefix=/usr/local –with-http_ssl_module

如果出现问题:
Undefined symbols for architecture x86_64:

重新配置:
./configure –with-ld-opt=”-L /usr/local/lib”

3. 安装
make
sudo make install

4. 安装后配置

/usr/local/nginx/conf/nginx.conf

server内增加:

location /test {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_connect_timeout 240;
proxy_send_timeout 240;
proxy_read_timeout 240;
# note, there is not SSL here! plain HTTP is used
proxy_pass http://localhost:8080;
}

5. 重启nginx,然后启动tomcat

sudo /usr/local/nginx/sbin/nginx

~/working/softwares/apache-tomcat-8.0.29/bin/startup.sh

6. 访问页面

curl “localhost:80/test/1.html”

参考:

http://nginx.org/en/docs/configure.html

https://kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/

https://trac.nginx.org/nginx/ticket/94

http://nginx.org/