One, reverse proxy
Nginx reverse proxy means that the Cross-domain URL becomes a request to the same domain through the local proxy, so as to solve the cross-domain problem
This configuration under the http://localhost/html5/path of the file to request http://localhost/request/related interface is equivalent to request http://localhost:8888/login/related interface
Second, the example
#user root owner; #在mac中获取权限时需要将注释去掉 worker_processes 2; #启动进程, usually set to the same number as the CPU events {worker_connections 1024; #单个后台worker The maximum number of concurrent links for process processes} HTTP {include MIME. Types
#设定mime类型, the type is defined by the Mime.type file Default_type application/octet-stream; #sendfile instruction Specifies whether Nginx calls the Sendfile function (zero copy) to output the file, for ordinary applications, #必须设为 on, if used for downloading applications disk IO Heavy load application, can be set to off to balance disk and network I/O processing speed, drop
Low-system uptime.
Sendfile on; Keepalive_timeout 65;
#连接超时时间 Server {listen #侦听80端口 server_name localhost; # defines using www.xx.com to access CharSet utf-8;
Location/{root HTML;
Add_header Cache-control No-store;
Add_header ' Access-control-allow-origin ';
Index index.html index.htm;
} location/request/{root/; Proxy_set_header Host $host;
#请求主机头字段, otherwise the server name. Proxy_headers_hash_max_size 1024; #存放http报文头的哈希表容量上限, the default is 512 characters proxy_headers_hash_bucket_size 128; #设The Header hash table size defaults to the Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Proxy_set_header accept-encoding ""; Proxy_pass http://localhost:8888/login/;
#请求替换地址 For example to request http://localhost:8888/login/is to request http://localhost/request/} location ~ ^/html5/{ REWRITE/HTML5 (. *) $ break; #该指令根据表达式来重定向URI, there are/html5/expires-1 in the path; #缓存 root D:\HTML5; #前端静态文件物理路径 access to the folders under D disk HTML5}} via http://localhost/html5/