mac 版nginx使用

第一步是要下载nginx ,网上有很多安装命令就不说了

第二步打开nginx 我的mac命令 open /usr/local/etc/nginx

第三步打开nginx.conf 把http 除了include servers/* 匹配所有 这个可以开多个端口号

user  www;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';

        #access_log  logs/access.log  main;

        sendfile        on;
        #tcp_nopush     on;

        #keepalive_timeout  0;
        keepalive_timeout  65;

        #gzip  on;

        include       site_conf/*.conf;


        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
       #    listen       8000;
       #    listen       somename:8080;
       #    server_name  somename  alias  another.alias;

       #    location / {
       #        root   html;
       #        index  index.html index.htm;
       #    }
       #}


# HTTPS server
#
#server {
#    listen       443 ssl;
#    server_name  localhost;

#    ssl_certificate      cert.pem;
#    ssl_certificate_key  cert.key;

#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

#    ssl_ciphers  HIGH:!aNULL:!MD5;
#    ssl_prefer_server_ciphers  on;

#    location / {
#        root   html;
#        index  index.html index.htm;
#    }
#}
include servers/*;
}

匹配其中一个端口号 8085

  server {
    listen       8085;
    server_name  localhost;

    location / {
        add_header Access-Control-Allow-Origin *;
        client_max_body_size 10m;
    }


    location ~ .*\.(gif|jpg|jpeg|png|ico|rar|zip|text|flv|bmp|swf|pdf|xls|ppt|doc|json|js|css|html|shtml|htm|map|woff|ttf)$ {
        add_header Access-Control-Allow-Origin *;
        #root  /Users/liuping/gx-web/src/;
        #root  /Users/liuping/gx-cms/src/;
        #root  /Users/liuping/Switching_to_Angular2/;
        root  /Users/liuping/gxMesVersions2/dist/;
        access_log off;
        expires 30d;
    }

    location ~  {
        #root   /Users/liuping/gx-web/src/;
        #root  /Users/liuping/gx-cms/src/;
        #root  /Users/liuping/Switching_to_Angular2/;
        #root    /Users/liuping/cmsUseNg2/dist/;
        index  app/index.html;
        #proxy_pass  http://www.gxcards.com;
       	#proxy_pass  http://twww.gxcards.com;
        #proxy_pass  http://mms.gxcards.com;
        #proxy_pass  http://tmms.gxcards.com;
        #e
        proxy_pass  http://101.201.51.207:7113;
        add_header Access-Control-Allow-Origin *;
        proxy_pass_header Server;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
    }

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

猜你喜欢

转载自my.oschina.net/u/3312137/blog/1602416