浏览 594
安装一个nginx,有静态网页(端口是22222),后台有一个服务(前台可以调用它的HTTP API,端口是8888
写了一个跳转的location,但是显示报错还是http://150.138.84.46:22222/api/db/v1/getmode 404 no found?
nginx的default.conf
location /api/db/v1/ {
proxy_pass http://localhost:8888;
proxy_set_header Host $host:$server_port;
proxy_redirect off;
proxy_http_version 1.1;
按点赞数排序
按时间排序
默认采用RoundRobin算法,主要基于TCP层和HTTP层实现健康检查。
其中,TCP层通过在建立连接、发送、接收消息时实现健康检查;HTTP层主要通过response code实现;一旦出错,会启动next upstream机制去解决错误。
不应该这么来弄,应该是结合lua/njs来做,通过njs/lua来判断文件是否存在
error_log stderr notice;
daemon off;
events { }
http {
include /usr/local/openresty/nginx/conf/mime.types;
server {
listen 80;
location @image_server {
content_by_lua_file "file_judge.lua";
}
location ~ ^/images/(?<sig>[^/]+)/(?<size>[^/]+)/(?<path>.*\.(?<ext>[a-z_]*))$ {
root cache;
set_md5 $digest "$size/$path";
try_files /$digest.$ext @image_server;
}
}
}
-- make sure the file exists
local file = io.open(source_fname)
if not file then
return_not_found()
end
file:close()
lua里面去判断文件存不存在