Skip to content

Instantly share code, notes, and snippets.

@lawvs
Last active May 25, 2018 12:01
Show Gist options
  • Save lawvs/4d28ea24548a8a027a84f163b863bec9 to your computer and use it in GitHub Desktop.
Save lawvs/4d28ea24548a8a027a84f163b863bec9 to your computer and use it in GitHub Desktop.
nginx配置
-- lua添加hearder
ngx.header['TEST']= test;
server {
listen 8080;
server_name 127.0.0.1;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html/www/dist; # 静态文件目录
index index.html;
try_files $uri $uri/ /index.html; # 按顺序检查文件是否存在 都不存在则内部重定向到最后一个参数
}
location /api {
# proxy_set_header Host $http_host;
add_header 'Access-Control-Allow-Origin' '*';
if ($request_method ~* "OPTIONS") { # 响应OPTIONS
return 200;
}
# return 301 $scheme://domain.com$request_uri; # 301 跳转
# 修改url参数 添加token
# set $args "$args&token=123456";
proxy_pass http://127.0.0.1:5000/api;
}
}
server {
listen 80;
location /test {
return 200 "TEST";
}
}
include vhost/*.host;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment