通过nginx反向代理访问spring boot应用程序时出现404



我有一个spring引导应用程序在我的本地mac上运行,端口为9096。

当我点击:

http://localhost:9096/murtaza

我得到所需的响应字符串'murtaza'。

现在,当我尝试使用nginx配置反向代理时,我一直得到404错误。这是我的nginx.conf文件:

#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#pid        logs/nginx.pid;

events {
worker_connections  1024;
}

http {
include       mime.types;
default_type  application/octet-stream;
#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                  '$status $body_bytes_sent "$http_referer" '
#                 '"$http_user_agent" "$http_x_forwarded_for"';
#access_log  logs/access.log  main;
sendfile        on;
#tcp_nopush     on;
#keepalive_timeout  0;
keepalive_timeout  65;
#gzip  on;
server {
listen       9070;
server_name  localhost;
#charset koi8-r;
#access_log  logs/host.access.log  main;
location / {
root   html;
index  index.html index.htm;
}
location = /murtaza {
proxy_pass http://localhost:9096/murtaza; 
}
#error_page  404              /404.html;
# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   html;
}
}
include servers/*;

}

我点击的url是

http://localhost:9070/murtaza

所以,配置是完美的。做一个,

brew services info nginx

显示我的nginx是loaded而不是running。必须重新启动主机并允许nginx从防火墙,然后重新启动使用,

brew services start nginx

让事情顺利进行。

相关内容

最新更新