header

mac 安装编译 nginx

1. http://nginx.org/en/download.html

2. tar -xf nginx-1.2.0.tar.gz

3. 进入解压目录  chmod a+rwx *

4. ./configure --without-http_rewrite_module

./configure --without-http_rewrite_module --with-http_ssl_module

5. sudo make && sudo make install

6. sudo /usr/local/nginx/sbin/nginx

6.5 浏览器访问 localhost

7. sudo /usr/local/nginx/sbin/nginx -s stop(重启reload)

 

默认的安装目录在 /usr/local/nginx/ 下

查看nginx的运行信息

ps -aux|grep nginx

 

代理解析 proxy_pass 定义了要代理的URL
upstream llc_app {
server 192.168.0.119:3100;
# server 172.16.0.114:3100;
}

server {
listen 80;
server_name localhost logan.ren linlc.cn;

location / {
# proxy_redirect off;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header Host $http_host;
# proxy_set_header X-NginX-Proxy true;
# proxy_set_header Connection "";
# proxy_http_version 1.1;
proxy_pass http://llc_app;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

#location ~ /\.ht {
# deny all;
#}
}

 

302重定向

location /doc/ {
    proxy_pass http://dcsapi.com/;
    proxy_redirect http://p.dcsapi.com/ /dcs/;
}
location /dcs/{
    proxy_pass http://p.dcsapi.com/;
}

~ 正则匹配()

location ~ /c5app/.+\.html {
    root html;
    index index.html;
}
location /c5app/ {
    proxy_pass http://123.56.20.159:8001/;
}
location ~ (/newmedia_app|/chatSseAction) {
    proxy_pass http://123.56.20.159:8001;
}

 

posted @ 2016-04-26 22:10  loganv  阅读(841)  评论(0)    收藏  举报
footer