Nginx 修改nginx.conf文件
location / {
proxy_pass http://balance;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
Tomcat修改 server.xml
<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="%{X-Real-IP}i %l %u %t "%r" %s %b" />
</Host>
Nginx与Tomcat配置详解
本文详细介绍了如何配置Nginx的nginx.conf文件实现反向代理、跨域访问等功能,并展示了如何设置Tomcat的server.xml以适配Nginx的日志需求,包括自定义访问日志的格式。
1678

被折叠的 条评论
为什么被折叠?



