Heim  >  Artikel  >  Backend-Entwicklung  >  nginx反向代理多个tomcat 配置解决因404问题js css无法加载问题 myeclipse tomcat配置 tomcat 下载 eclipse配置tomcat

nginx反向代理多个tomcat 配置解决因404问题js css无法加载问题 myeclipse tomcat配置 tomcat 下载 eclipse配置tomcat

WBOY
WBOYOriginal
2016-07-29 08:50:014249Durchsuche

首先nginx tomcat 的安装解压.网上资料很多.不予赘述.

这里主要是使用nginx 实现对多个tomcat的代理配置. 首先nginx 的配置文件为conf/ngins.conf;

描述场景  有8080端口下Tomcat1下项目A.

                  有8090端口下tomcat2下项目B.

                   ......

通过使用一个域名+(不同)项目名 访问不同的tomcat下的项目.

配置文件如下:(均在conf文件内添加即可  不删除或修改其他内容).

server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;

            location /Name1 {
            #root  html;
   proxy_pass http://localhost:8080/A ;
   proxy_redirect   http://host:8080 http://$host:$server_port;//这个配置是将我们的host主机名和端口号,被host:8080所替代.不然因为域名问题,加载js,css文件会报404错误.
            index  index.html index.htm;
        }
location /Name2 {
            #root  html;
   proxy_pass http://localhost:8090/B;
   proxy_redirect   http://host:8090 http://$host:$server_port;
            index  index.html index.htm;
        }

..........省略

}

配置保存,重启.吐槽一下nginx的重启运行.很麻烦.我是在任务管理器内直接停止后重启的.

以上即可实现 localhost+A-------访问tomcat A项目

                         localhost+B-------访问tomcat B项目

以上就介绍了nginx反向代理多个tomcat 配置解决因404问题js css无法加载问题,包括了tomcat 配置方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn