应用场景
跨域配置
- 关上根目录下的
conf/nginx.conf
文件
- 在server配置跨域转发解决
location / {
root html;
index index.html index.htm;
proxy_pass yuming.com; #须要拜访的接口域名
}
add_header Access-Control-Allow-Origin *; #设置跨域域名
add_header Access-Control-Allow-Credentials true; #携带cookie
if ( $request_method = 'OPTIONS' ) { #拦挡options申请
return 200;
}
#应用`http://localhost/接口地址`拜访
nginx常用命令
- nginx启动命令 start nginx(举荐) / nginx.exe(用这个命令cmd窗口就不能完结了,只能重开)
- nginx进行命令 nginx -s stop(当应用nginx.exe命令启动时,应用这个有效)
- nginx重启命令 nginx -s reload(重载nginx命令,当你扭转了nginx配置信息并须要从新载入这些配置时能够应用此命令重载nginx)
发表回复