1、修改hosts文件,解析DNS
2、nginx.conf
3、在tomcat的server.xml中增加host
这时候就可以通过域名访问应用了
127.0.0.1 nexus.seven7.org
127.0.0.1 bbs.seven7.org
127.0.0.1 wiki.seven7.org
2、nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
upstream bbs.seven7.org {
server 127.0.0.1:8080 weight=9 max_fails=0;
#server 127.0.0.1:8082 backup;
}
upstream wiki.seven7.org {
server 127.0.0.1:8080 weight=9 max_fails=0;
#server 127.0.0.1:8082 backup;
}
upstream nexus.seven7.org {
server 127.0.0.1:8090 weight=9 max_fails=0;
#server 127.0.0.1:8082 backup;
}
include mime.types;
default_type application/octet-stream;
client_max_body_size 10m;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 65;
#FastCGI通用配置
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
#gzip on;
#gzip_min_length 1000;
#gzip_buffers 4 16k;
#gzip_comp_level 5;
#gzip_types text/plain application/x-javascript text/css application/xml;
#gzip_http_version 1.1;
#gzip_proxied expired no-cache no-store private auth;
#gzip_disable "MSIE \.";
#gzip_vary on;
server {
listen 80;
server_name bbs.seven7.org;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.jsp;
proxy_pass http://bbs.seven7.org;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name wiki.seven7.org;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.jsp;
proxy_pass http://wiki.seven7.org;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name nexus.seven7.org;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.jsp;
proxy_pass http://nexus.seven7.org;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
3、在tomcat的server.xml中增加host
<Host name="bbs.seven7.org" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="D:/workspace/j2ee/apache-tomcat-6.0.20/webapps/bbs" debug="0"></Context>
</Host>
<Host name="wiki.seven7.org" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="" docBase="D:/workspace/j2ee/apache-tomcat-6.0.20/webapps/wiki" debug="0"></Context>
</Host>
这时候就可以通过域名访问应用了