Html nginx配置前端和后端
我有一个后端运行在Html nginx配置前端和后端,html,nginx,webserver,Html,Nginx,Webserver,我有一个后端运行在localhost:8080。路径/runFuction执行某个命令 现在我想使用nginx作为前端的web服务器,只向后端发送某些请求 我的nginx配置如下所示 server { listen 80; server_name localhost; location / { root <path to site>; index index.html index.htm; }
localhost:8080
。路径/runFuction
执行某个命令
现在我想使用nginx作为前端的web服务器,只向后端发送某些请求
我的nginx配置如下所示
server {
listen 80;
server_name localhost;
location / {
root <path to site>;
index index.html index.htm;
}
location /api {
proxy_pass http://localhost:8080/;
}
}
我以为这是可能的,但不知为什么我错过了一些东西。既然我总是得到一个不在那里的404页面,我如何到达后端路径?你能试试吗
location /api/ {
rewrite ^/api^/ /$1 break;
proxy_pass http://localhost:8080;
}
你能试试吗
location /api/ {
rewrite ^/api^/ /$1 break;
proxy_pass http://localhost:8080;
}
非常感谢你。为什么总是这些小错误。我想是正则表达式修正了它。非常感谢。为什么总是这些小错误。我想正是正则表达式纠正了这一点。