Home > Backend Development > PHP Tutorial > nginx tomcat configures multiple second-level domain names and multiple projects

nginx tomcat configures multiple second-level domain names and multiple projects

WBOY
Release: 2016-08-08 09:24:02
Original
1459 people have browsed it

What I want is to access news.test.com. What I actually access is the news project under tomcat. When I visit forum.test.com, what I actually access is the luntan project under tomcat, but the browser address bar url News.test.com and forum.test.com remain unchanged. Do not change them to news.test.com/news or forum.test.com/luntan. How to configure them? Please advise

Thank you for your answers, it has been solved. You need to configure a virtual host in tomcat. The host name is the domain name that needs to be accessed.
path="" docBase="/opt/tomcat/webapps/news" . If there is no access path after the domain name of the homepage. path needs to be "". docBase points to the project name. Share it with everyone here. Thank you again for your answers, ^_^

<ol>
<li><span>server</span></li>
<li>
<span></span><span>{</span><span></span>
</li>
<li>
<span>    listen </span><span>80</span><span>;</span><span></span>
</li>
<li>
<span>    server_name news</span><span>.</span><span>test</span><span>.</span><span>com</span><span>;</span><span></span><span>//前台访问地址</span><span></span>
</li>
<li>
<span>    root </span><span>{</span><span>WEB_ROOT_PATH</span><span>}/</span><span>news</span><span>;</span><span></span>
</li>
<li>
<span>    access_log </span><span>{</span><span>LOG_ROOT_PATH</span><span>}/</span><span>news</span><span>.</span><span>log</span><span>;</span><span></span>
</li>
<li>
<span>    location </span><span>/</span><span></span><span>{</span><span>  </span>
</li>
<li>
<span>        proxy_pass http</span><span>:</span><span>//news; //tomcat后台处理地址</span><span></span>
</li>
<li>
<span>    </span><span>}</span><span>  </span>
</li>
<li>
<span></span><span>}</span><span></span>
</li>
<li><span>server</span></li>
<li>
<span></span><span>{</span><span></span>
</li>
<li>
<span>    listen </span><span>80</span><span>;</span><span></span>
</li>
<li>
<span>    server_name forum</span><span>.</span><span>test</span><span>.</span><span>com</span><span>;</span><span></span><span>//前台访问地址</span><span></span>
</li>
<li>
<span>    root </span><span>{</span><span>WEB_ROOT_PATH</span><span>}/</span><span>forum</span><span>;</span><span></span>
</li>
<li>
<span>    access_log </span><span>{</span><span>LOG_ROOT_PATH</span><span>}/</span><span>forum</span><span>.</span><span>log</span><span>;</span><span></span>
</li>
<li>
<span>    location </span><span>/</span><span></span><span>{</span><span>  </span>
</li>
<li>
<span>        proxy_pass http</span><span>:</span><span>//forum; //tomcat后台处理地址</span><span></span>
</li>
<li>
<span>    </span><span>}</span><span>  </span>
</li>
<li>
<span></span><span>}</span>
</li>
</ol>
Copy after login

The above introduces nginx tomcat configuration of multiple second-level domain names and multiple projects, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template