apache 配置动静分离,允许跨域, 并在反向代理的情况下维持默认主页
来源:互联网 发布:淘宝店怎么提升销量 编辑:程序博客网 时间:2024/05/01 09:33
修改httpd.conf
<VirtualHost *:80> ServerName app.taotianyue.com DocumentRoot /data/web/guanwang_app/static_src ErrorLog /data/web/guanwang_app/apache_error.log ServerAdmin 346126185@.qq.comHeader set Access-Control-Allow-Origin * ProxyRequests Off ProxyPreserveHost On ProxyPassMatch /*.jpg ! ProxyPassMatch /*.mp4 ! ProxyPassMatch /*.css ! ProxyPassMatch /*.gif ! ProxyPassMatch /*.png ! ProxyPassMatch /*.js ! ProxyPassMatch /*.html$ ! ProxyPass /test.html ! ProxyPass /index.html ! ProxyPassMatch ^/$ ! ProxyPass / http://127.0.0.1:8123/ ProxyPassReverse / http://127.0.0.1:8123/ <Directory "/data/web/guanwang_app/static_src"> Options -Indexes AllowOverride None Order allow,deny Allow from all DirectoryIndex index.html </Directory></VirtualHost>
说明
<VirtualHost *:80>
ServerName app.gaotianyue.com #域名
DocumentRoot /data/web/guanwang_app/static_src #静态资源目录
ErrorLog /data/web/guanwang_app/apache_error.log
ServerAdmin 346126185@qq.com
Header set Access-Control-Allow-Origin * #允许跨域
ProxyRequests Off
ProxyPreserveHost On
ProxyPassMatch /*.jpg !
ProxyPassMatch /*.mp4 !
ProxyPassMatch /*.css !
ProxyPassMatch /*.gif !
ProxyPassMatch /*.png !
ProxyPassMatch /*.js !
ProxyPassMatch /*.html$ ! #ProxyPassMatch 允许通配符
ProxyPass /test.html ! #ProxyPass不允许通配符
ProxyPassMatch ^/$ ! # 仅仅匹配 / ,而不匹配任何字符,这样使得访问域名绕过反向代理而使默认主页的设置不失效
ProxyPass / http://127.0.0.1:8123/
ProxyPassReverse / http://127.0.0.1:8123/
<Directory "/data/web/guanwang_app/static_src">
Options -Indexes
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.html 默认主页
</Directory>
</VirtualHost>
为了更直观些,我截了个图
现在有种情况要对 /mg/文件夹下的html,css等资源也同样代理,但是其他的html,css等不代理,则么做?
添加
ProxyPassMatch /mg/ http://127.0.0.1:8123/
即可
<VirtualHost *:80>
ServerName app.sincetimes.com
DocumentRoot /data/web/guanwang_app/static_src
ErrorLog /data/web/guanwang_app/apache_error.log
Header set Access-Control-Allow-Origin *
ProxyRequests Off
ProxyPreserveHost On
ProxyPassMatch /mg/ http://127.0.0.1:8123/
ProxyPassMatch /*.jpg !
ProxyPassMatch /*.mp4 !
ProxyPassMatch /*.css !
ProxyPassMatch /*.gif !
ProxyPassMatch /*.png !
ProxyPassMatch /*.js !
ProxyPassMatch /*.html$ !
ProxyPass /test.html !
ProxyPass /index.html !
ProxyPassMatch ^/$ !
ProxyPass / http://127.0.0.1:8123/
ProxyPassReverse / http://127.0.0.1:8123/
<Directory "/">
Options -Indexes
AllowOverride None
Order allow,deny
Allow from all
Header set Access-Control-Allow-Origin *
DirectoryIndex index.html
</Directory>
</VirtualHost>
- apache 配置动静分离,允许跨域, 并在反向代理的情况下维持默认主页
- 反向代理实现nginx+apache动静分离
- 反向代理实现nginx+apache动静分离
- nginx配置反向代理及动静分离
- nginx(11) nginx 配置动静分离,设置默认主页,限制某个路径的资源代理全解
- Nginx 反向代理,负载均衡,动静分离配置
- nginx的配置及以反向代理方式实现动静分离、负载均衡
- nginx 反向代理及动静分离
- nginx、tomcat实现动静分离,反向代理
- 五.Nginx反向代理与动静分离
- nginx反向代理tomcat实现动静分离
- nginx反向代理、动静分离、负载均衡
- apache + tomcat动静分离配置
- Nginx服务器安装详情及配置:反向代理+动静分离+负载均衡+keepalived实现高可用
- Nginx与Apache、Tomcat、Resin动静分离的配置
- Apache反向代理的配置
- Apache配置默认主页
- nginx负载均衡/反向代理+tomcat动静分离
- Windows下查询域名的DNS TXT记录的命令
- poj_2065 SETI(高斯消元解同余方程组)
- hashmapper的使用以及json字符串与普通字符串的差异
- Linux下使用shell解压打包jar包
- 【算法模板】图论
- apache 配置动静分离,允许跨域, 并在反向代理的情况下维持默认主页
- pjsip
- Y2K Accounting Bug(POJ 2586)(贪心)
- 没有卑微
- 什么是hack技术
- Linux下MySQL安装与配置
- Opencv(py/vs)
- 简单三步:iOS配置HTTPS支持苹果ATS?
- JavaScript Navigator