標籤:real default 網域名稱 har .com style 修改 org java
首先配置:nginx
# cd /etc/nginx/conf.d/# cp default.conf tomcat.conf# nano tomcat.conf
請在tomcat.conf裡輸入:
server { listen 80; server_name mydomain.com; index index.jsp; root /usr/share/nginx/html/h5; location / { proxy_pass http://mydomain.com:8080; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
這裡請注意:mydomain.com是你的網域名稱,/usr/share/nginx/html/h5是你的項目路徑,要與下面的tomcat對應起來.
其次,修改Server.xml
# nano /usr/local/tomcat/conf/server.xml
請修改如下:
<Host name="mydomain.com" appBase="/usr/share/nginx/html/h5" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/usr/share/nginx/html/h5" debug="0" reloadable="false" crossContext="tr$ <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
CentOS7 nginx+tomcat實現代理訪問java web項目讓項目支援jsp和php