我正在尝试在nginx上设置子域名.我的设置是在端口8080上运行并使用来自nginx的代理的Pylons应用程序.
我试图让子域工作的原因是最终设置dev和staging服务器.
这是我的nginx.conf文件:
worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
access_log logs/rentfox.access.log;
error_log logs/rentfox.error.log;
gzip on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75 20;
server {
listen 80;
server_name xxx.net;
location / {
include /usr/local/nginx/conf/proxy.conf;
proxy_pass http://127.0.0.1:8080;
proxy_redirect default;
root /var/apps/xxx/xxx/public/;
}
#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;
}
}
server {
listen 80; …
Run Code Online (Sandbox Code Playgroud) 在我的项目中,使用Spring引导和默认的tomcat服务器开发Web应用程序.我使用NGINX作为负载均衡器,并在NGINX配置中配置了我的spring-boot-web-app,如下所示:
location /spring-boot-web-app {
proxy_pass http://spring-boot-web-app/
}
http {
upstream /spring-boot-web-app {
server <IP_of_spring_boot_app>:<Port_of_spring_boot_app>
}
}
Run Code Online (Sandbox Code Playgroud)
现在让我们分别说NGINX IP和端口为nginx_ip和nginx_port.我的网络应用程序的工作URL也是:http:// web_app_ip:web_app_port/rest/echo/hi
上面的URL工作正常.但是当我尝试通过NGINX点击相同的URI时,它会抛出404.通过NGINX使用的URL为: http:// nginx_ip:nginx_port/spring-boot-web-app/rest/echo/hi
有什么我想念的吗?