Spring Boot and Nginx integration

痴心易碎 提交于 2019-12-02 19:49:46

This works for me. Can you try this?

  1. Running tomcat

    docker run -d -p 8080:8080 --name=tomcat tomcat:8 
    
  2. Running nginx

    docker run -d -p 80:80 --link tomcat:tomcat --name=nginx nginx
    
  3. Go inside nginx container and update the conf

    docker exec -it nginx bash
    

    /etc/nginx/nginx.conf:

    server {
       listen 80 default_server;
      server_name subdomain.domain.com;
      location / {
          proxy_pass http://tomcat:8080;
          proxy_set_header Host      $host;
          proxy_set_header X-Real-IP $remote_addr;
      }
    }
    
  4. Restart nginx service

    nginx -s reload
    
  5. Access the tomcat through nginx from host browser. You may need to add entry to /etc/hosts

    http://subdomain.domain.com
    

Complete nginx conf: nginx.conf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!