三.apache 网页重写 squid
#######网页重写########
把所有80端口的请求全部重定向由https来处理
systemctl start httpd firewalld
cd /var/www/html/
[root@mailwestos html]# firewall-cmd --permanent --add-service=http
success
[root@mailwestos html]# firewall-cmd --permanent --add-service=https
success
[root@mailwestos html]# firewall-cmd --reload
yum install mod_ssl
安装https
genkey www.westos.com
[root@mailwestos conf.d]# vim news.conf
---------------------------------------
<Virtualhost *:80>
ServerName news.westos.com
DocumentRoot /var/www/virtual/news/html
Customlog logs/news.log combined
</Virtualhost>
<Directory "/var/www/virtual/news/html">
Require all granted
</Directory>
------------------------------------------
[root@mailwestos conf.d]# cp news.conf ent.conf
[root@mailwestos conf.d]# vim ent.conf
------------------------------------------
<Virtualhost *:80>
ServerName ent.westos.com
DocumentRoot /var/www/virtual/ent/html
Customlog logs/ent.log combined
</Virtualhost>
<Directory "/var/www/virtual/ent/html">
Require all granted
</Directory>
-------------------------------------------
mkdir -p /var/www/virtual/ent/html
mkdir -p /var/www/virtual/news/html
echo news.westos.com > /var/www/virtual/news/html/index.html
echo ent.westos.com > /var/www/virtual/ent/html/index.html
systemctl restart httpd
vim /etc/httpd/conf.d/news.conf ##网页重写关键一步
-----------------------------------------------------------
<Virtualhost *:80>
ServerName news.westos.com
RewriteEngine on
RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</Virtualhost>
<Directory "/var/www/virtual/news/html">
Require all granted
</Directory>
<Virtualhost *:443>
ServerName news.westos.com
DocumentRoot /var/www/virtual/news/html
Customlog log/news-443.log combined
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
</Virtualhost>
--------------------------------------------------------------
##在vim中 :sp /etc/httpd/conf.d/ssl.conf 可以在vim中在打开另一个vim
##将两个文件分屏显示,使用"ctrl+w 上|下"来切换
用firefox测试
#####CGI#####
CGI
通用网关接口(CGI)是网站上放置动态内容的最简单的方法。CGI脚本可用于许多目
的,但是谨慎控制使用哪个CGI脚本以及允许谁添加和运行这些脚本十分重要。编写质量差的CGI
脚本可能为外部***者提供了破坏网站及其内容安全性的途径。因此,在Web服务器级别和
SELinux策略级别,都存在用于限制CGI脚本使用的设置。
cd /var/www/html/
vim index.php
<?php
phpinfo ();
?>
vim /etc/httpd/conf/httpd.conf
-----------------------------------------------
164 DirectoryIndex index.php index.html
:wq
-----------------------------------------------
systemctl reload httpd.service
测试:http://172.25.254.100(需清空缓存:ctrl+shift+delete)
无任何显示
mkdir cgi
cd cgi/
vim index.cgi
---------------------------------
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print `date`;
---------------------------------
yum install httpd-manual -y
172.25.254.100/manual/
[root@mailwestos cgi]# perl index.cgi
Content-type: text/html
2016年 12月 15日 星期四 06:05:17 EST
vim /etc/httpd/conf.d/default.conf
---------------------------------------------
<Virtualhost _default_:80>
Documentroot /var/www/html
Customlog logs/default.log combined
</Virtualhost>
<Directory "/var/www/html/cgi">
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>
----------------------------------------------
设置安全上下文
[root@mailwestos www]# ls -Zd cgi-bin/
drwxr-xr-x. root root system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin/
[root@mailwestos www]# semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/html/cgi(/.*)?'
[root@mailwestos www]# restorecon -RvvF /var/www/html/cgi/
restorecon reset /var/www/html/cgi context unconfined_u:object_r:httpd_sys_content_t:s0->system_u:object_r:httpd_sys_script_exec_t:s0
restorecon reset /var/www/html/cgi/index.cgi context unconfined_u:object_r:httpd_sys_content_t:s0->system_u:object_r:httpd_sys_script_exec_t:s0
chmod +x /var/www/html/cgi/index.cgi ##加执行权限
检验
172.25.254.100/cgi/index.cgi
Thu Dec 15 06:20:37 EST 2016
########论坛搭建########
[root@mailwestos conf.d]# yum install mariadb-server -y
......
[root@mailwestos conf.d]# vim /etc/my.cnf
-----------------------------------------------
10 skip-networking=1
:wq
-----------------------------------------------
[root@mailwestos conf.d]# systemctl start mariadb
[root@mailwestos conf.d]# mysql_secure_installation
......
>Set root password "westos"
[root@mailwestos conf.d]# cd /var/www/html/
[root@mailwestos html]# ls
cgi index.html index.php
[root@foundation50 pub]# pwd
/root/Documents/RHCE/LFTP/pub
[root@foundation50 pub]# scp Discuz_X3.2_SC_UTF8.zip root@172.25.254.100:/var/www/html/
root@172.25.254.100's password:
Discuz_X3.2_SC_UTF8.zip 100% 12MB 11.9MB/s 00:01
[root@mailwestos html]# ls
cgi Discuz_X3.2_SC_UTF8.zip index.html index.php
[root@mailwestos html]# unzip Discuz_X3.2_SC_UTF8.zip
......
[root@mailwestos html]# ls
cgi Discuz_X3.2_SC_UTF8.zip index.html index.php readme upload utility
[root@mailwestos html]# less readme/readme.txt
-----------------------------------------------
截取重要内容:
+----------------------------------+
Discuz! X 社区软件的安装
+----------------------------------+
1. 上传 upload 目录中的文件到服务器
2. 设置目录属性(windows 服务器可忽略这一步)
以下这些目录需要可读写权限
./config
./data 含子目录
3. 执行安装脚本 /install/
请在浏览器中运行 install 程序,即访问 http://您的域名/论坛目录/install/
4. 参照页面提示,进行安装,直至安装完毕
-----------------------------------------------
[root@mailwestos html]# chmod 777 upload/data/ upload/config/
>测试:http://172.25.50.100/upload/
-->我同意
>所有文件不可写,mysql不支持
[root@mailwestos html]# setenforce 0
>刷新网页
>只有前4个文件显示可写,mysql不支持
[root@mailwestos html]# chmod 777 upload/ -R
>刷新网页
>所有文件可写,mysql不支持
[root@mailwestos html]# yum install php-mysql -y
......
[root@mailwestos html]# systemctl reload httpd
测试
>刷新网页
>所有文件可写,mysql支持
-->下一步-->下一步
-->数据库密码:westos-->管理员密码:(自行设定)-->下一步
>等待安装完成,重新输入网址:http://172.25.50.100/upload/
>安装成功!!!
--安装完成,以下为体验--
-->输入管理员密码-->登陆-->输入验证码-->登陆
-->用户组:管理员
-->模块管理
-->管理中心
########squid正向代理#######
[root@foundation50 ~]# ls /etc/httpd/conf.d/
autoindex.conf README userdir.conf welcome.conf
[root@foundation50 ~]# yum install squid -y
......
[root@foundation50 ~]# ls /etc/httpd/conf.d/
autoindex.conf README squid.conf userdir.conf welcome.conf
[root@foundation50 ~]# vim /etc/squid/squid.conf
-----------------------------------------------
56 http_access allow all
62 cache_dir ufs /var/spool/squid 100 16 256
:wq
-----------------------------------------------
[root@foundation50 ~]# ls /var/spool/squid/
##什么都没有
[root@foundation50 ~]# systemctl start squid
[root@foundation50 ~]# systemctl enable squid.service
Created symlink from /etc/systemd/system/multi-user.target.wants/squid.service to /usr/lib/systemd/system/squid.service.
[root@foundation50 ~]# netstat -antlpe |grep squid
tcp6 0 0 :::3128 :::* LISTEN 0 531476 7398/(squid-1)
[root@web1 conf.d]# firefox &
>测试:www.baidu.com
>提示:一直是"Connecting..."状态
-->Edit-->Preferences-->Advanced-->Network-->Settings...
-->Manual proxy configuration-->HTTP Proxy:172.25.50.250-->Port:3128
-->OK-->Close
>再次测试:www.baidu.com
>打开百度成功!!!
--取消代理--
-->Edit-->Preferences-->Advanced-->Network-->Settings...
-->Manual proxy configuration-->No proxy
-->OK-->Close
--删除squid服务--
[root@foundation50 ~]# systemctl stop squid
[root@foundation50 ~]# yum remove squid -y
......
[root@foundation50 ~]# rm -fr /etc/squid/
在亚马逊租一台Linux服务器,装上squid,然后在本机指定代理后,就能访问国外的网站
#########squid反向代理#########
CDN加速
交叉存储
[root@web1 ~]# yum remove httpd -y
......
[root@web1 ~]# netstat -antlpe |grep :80
[root@web1 ~]# yum install squid -y
......
[root@web1 ~]# vim /etc/squid/squid.conf
-----------------------------------------------
56 http_access allow all
59 http_port 80 vhost vport
60 cache_peer 172.25.50.165 parent 80 0 no-query
62 cache_dir ufs /var/spool/squid 100 16 256
:wq
-----------------------------------------------
[root@web1 ~]# systemctl start squid
[root@web1 ~]# netstat -antlpe |grep :80
tcp6 0 0 :::80 :::* LISTEN 0 41808 2069/(squid-1)
>分别为虚拟机172.25.50.165和虚拟机172.25.50.171搭建好http服务,然后使用真机进行测试
[root@foundation50 Desktop]# firefox &
>测试:172.25.50.165
>显示:172.25.50.165
>测试:172.25.50.171
>显示:172.25.50.171
注意:同时开启三台虚拟机会有点卡,可以使用"init 3"关闭图形。需要时,再使用"init 5"打开图形
>测试:172.25.50.100
>显示:172.25.50.165
[root@web1 ~]# vim /etc/squid/squid.conf
-----------------------------------------------
/修改
60 cache_peer 172.25.50.165 parent 80 0 no-query originserver round-robin name=web1
/插入
61 cache_peer 172.25.50.171 parent 80 0 no-query originserver round-robin name=web2
62 cache_peer_domain web1 web2 www.taobao.com
:wq
-----------------------------------------------
[root@web1 ~]# systemctl restart squid
[root@foundation50 Desktop]# vim /etc/hosts
-----------------------------------------------
4 172.25.50.100 www.taobao.com
:wq
-----------------------------------------------
>真机断开外网
[root@foundation50 Desktop]# firefox &
--> Ctrl+Shift+Delete --> 把最后两项打钩 --> Clear Now(清空缓存)
>测试:172.25.50.100
>显示:172.25.50.165
>刷新
>显示:172.25.50.171
>刷新
>显示:172.25.50.165
>刷新
>显示:172.25.50.171
轮询测试成功
转载于:https://blog.51cto.com/12110661/1883191
三.apache 网页重写 squid相关推荐
- Linux 的Apache服务之https与网页重写
https 1.https概述: HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是 ...
- Apache网页优化 ---配置防盗链
防盗链概述 防盗链就是防止别人的网站代码里面盗用服务器的图片文件.视频等相关资源.如果别人盗用网站的这些静态资源,明显的是会增大服务器的带宽压力.所以作为网站的维护人员,要杜绝我们服务器的静态资源被其 ...
- 理论+实操:Apache 网页与安全优化
文章目录 一:Apache网页优化概述 1.1 优化内容 二:gzip介绍 配置apache的网页压缩功能,是使用gzip压缩算法来对网页内容进行压缩后再传输到客户端浏览器 作用 三:apache的压 ...
- Apache网页优化概述
Apache网页优化概述 Apache网页优化概述 一.网页压缩 1.检查是否安装mod_ deflate 模块 2.如果没有安装mod_deflate 模块,重新编译安装 Apache 添加 mod ...
- centos 7.6—— Apache网页压缩——网页缓存
centos 7.6-- Apache网页压缩和网页缓存 文章目录 centos 7.6-- Apache网页压缩和网页缓存 gzip 介绍 (1)作用 (2)Apache的压缩模块 (3)配置网页压 ...
- 企业微信三方开发(三):网页授权登录
其他链接 初识微信开发 企业微信三方开发:注册企业微信服务商 企业微信三方开发(一):回调验证及重要参数获取 企业微信三方开发(二):获取access_token 企业微信三方开发(三):网页授权登录 ...
- 手把手教你,嘴对嘴传达------Apache网页优化
文章目录 Apache网页优化 一.Apache网页压缩 1.网页优化概述 2. 网页gzip概述 3.Apache的压缩模块 4.配置网页压缩功能 5.Apache网页压缩实操 (1) 手动编译安装 ...
- 【Web网站服务】Apache网页优化
Apache网页优化 一.网页压缩 1.1网页压缩步骤 二.网页缓存 三.隐藏版本信息 五.Apache防盗链 一.网页压缩 在企业中,部署Apache后只采用默认的配置参数,会引发网站很多问题,换言 ...
- Apache网页优化和安全优化
文章目录 一.Apache网页优化 1.1网页压缩 1.2配置网页压缩功能并进行验证 1.3配置网页的缓存时间并进行验证 二.Apache安全优化 2.1配置防盗链 2.2隐藏版本信息 一.Apach ...
最新文章
- UML Distilled 3rd 学习笔记
- JavaSE 和 JavaEE 的关系
- java并发面试题(一)基础
- C#使用Cookie方法
- mt4软件较稳定的交易商服务器地址,外汇MetaTrader 4 常见交易商服务器ip地址汇总...
- 控制台总是输出:xcode error: failed to attach to process ID 0
- [转载] boost python numpy_boost.python 与 boost.numpy安装的一些注意事项
- 【ArcGIS|空间分析|网络分析】1 创建网络数据集
- FusionChartsFree的用法
- 找简历模板过程中的碎碎念
- 【扫盲】------Zipf分布
- NB-IOT紧急按钮
- 国家c语言计算机二级,国家计算机二级考试 C语言基本知识.pdf
- python 列表解析式
- 我写代码的这十年——致逝去的青春
- http协议学习(转载,侵删)
- 短视频系统开发时如何实现在iOS系统相册中选取视频
- [BZOJ3698] XWW的难题 网络流
- 苹果手机双卡双待是哪一款_手机双卡双待信号有区别吗手机主卡、副卡这些区别,早知道为好!...
- linux cp目录到指定目录,linux复制指定目录下的全部文件到另一个目录中,linux cp 文件夹...
热门文章
- 微信小程序四种父子相互传值方式
- python绘制音频频谱_Python 读取wav画频谱
- python识别复杂验证码2020_Python识别验证码!学会这步,百分之60的网站你基本都能识别了!...
- 20211027:《Labuladong的算法小抄》学习记录(一)
- pcie总线连接两台电脑_基于PCIE总线多主互连系统的设计与实现
- 华强北耳机检测软件_华强北神器不灵了?肢解500块最强山寨AirPods Pro:虚假降噪背后骗术翻车...
- jfianl中 解决jetty Form too large
- 加密解密你了解多少?
- Apple Watch,其实是个老司“机”
- 清华霸榜,长沙理工异军突起!第三届 CCF CCSP落下帷幕