反向代理的目的 : 不暴露真实IP地址,安全性更高
一. 修改c盘hosts文件(C:WindowsSystem32driversetc)
在文件末尾添加你的代理地址
二.修改nginx.conf配置文件
server { listen 80; server_name note.java.itcast.cn; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://note.java.itcast.cn; proxy_redirect default; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ .php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} }
配置完成后,启动nginx,启动tomcat
代理地址和ip地址访问的是同一个工程