Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NGINX-Spring启动应用程序(“/etc/NGINX/html/index.html”未找到)_Spring_Spring Boot_Docker_Nginx - Fatal编程技术网

NGINX-Spring启动应用程序(“/etc/NGINX/html/index.html”未找到)

NGINX-Spring启动应用程序(“/etc/NGINX/html/index.html”未找到),spring,spring-boot,docker,nginx,Spring,Spring Boot,Docker,Nginx,所以我有一个SpringBoot应用程序,我想把它放在nginx后面,问题是当访问本地主机时,我的连接被拒绝了 我的nginx配置是什么样子的: server { listen 80; server_name workaround; charset utf-8; access_log off; location / { proxy_pass http://172.19.0.3:8080/workaround; pr

所以我有一个SpringBoot应用程序,我想把它放在nginx后面,问题是当访问本地主机时,我的连接被拒绝了

我的nginx配置是什么样子的:

    server {

    listen 80;
    server_name workaround;
    charset utf-8;
    access_log off;


    location / {
       proxy_pass http://172.19.0.3:8080/workaround;
       proxy_set_header X-Real-IP         $remote_addr;
       proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
       proxy_set_header X-Forwarded-Host  $host;

     }
}
我跑步的内容:

我在访问localhost时得到的响应

404找不到。在我的docker compose文件中,为什么要查找一些etc/nginx/html/index

我的配置有什么问题?如何正确访问我的SB应用程序

我曾尝试使用localhost而不是不起作用的IP-bud。 因为它在应用程序未运行的地方使用了nginx ip。 我在考虑重写nginx bud的默认配置,我怎么能从dockerfile中做到这一点呢?既然卷已经设置了映射,为什么还要强迫我这么做呢。
好吧,我找到了答案,我甚至设法修复了它,使它能够与具有哈希前缀的资源一起工作:

events {
  worker_connections 1024;
}

http {

  server {
        listen 80;
        charset utf-8;
        access_log off;
        try_files $uri $uri/ =404;

        location / { #this still has to be here, otherwise i get ISE
            proxy_pass http://workaround:8085/;
        }

        location ^~ { #this thing fixes hashes and resources
            proxy_pass              $scheme://workaround:8085/$request_uri;
            proxy_redirect  off;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        Host $http_host;
            expires 30d;
         }
    }


}
events {
  worker_connections 1024;
}

http {

  server {
        listen 80;
        charset utf-8;
        access_log off;
        try_files $uri $uri/ =404;

        location / { #this still has to be here, otherwise i get ISE
            proxy_pass http://workaround:8085/;
        }

        location ^~ { #this thing fixes hashes and resources
            proxy_pass              $scheme://workaround:8085/$request_uri;
            proxy_redirect  off;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        Host $http_host;
            expires 30d;
         }
    }


}