nginx
代理上游资源proxy_pass
upstream mydomain{
server localhost:8080;
}
## 二级域名
upstream mydomain_book {
server localhost:8081;
}
监听80端口
server {
listen 80;
#域名【二级、三级域名等】,客户访问的URL
server_name www.mydomain.com;
location / {
#root html;
#index index.html index.htm;
#代理的访问路径upstream
proxy_pass http://onmybook;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_connect_timeout 3;
proxy_read_timeout 3;
proxy_send_timeout 3;
access_log off;
break;
}
tomcat
域名+端口的访问方式
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context
#访问根路径
path=""
#webapps的相对位置URI
docBase="/mydomain"
debug="true"
reloadable="false"
/>
<Valve
className="org.apache.catalina.valves.AccessLogValve"
directory="logs"
prefix="localhost_access_log"
suffix=".txt"
pattern="%h %l %u %t "%r" %s %b"
/>
</Host>
同一个域名配置多个端口
通过8080 和 8099两个端口访问同一个app。
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8099" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
|