虚拟主机加密与网页重写 squit服务

{**虚拟主机加密和网页重写apache**}

做好https认证以后

hostnamectl set-hostname web1.example.com

logout

vim /etc/httpd/conf.d/ssl.conf

cd /etc/httpd/conf.d/

vim news.conf

<Virtualhost *:80>

Servername news.westos.com

Documentroot /var/www/virtual/news.westos.com/html

Customlog logs/news.log       combined

</Virtualhost>

<Directory "/var/www/virtual/news.westos.com/html">

Require all granted

</Directory>

<Virtualhost *:443>                    **可以访问443端口(https端口)

Servername news.westos.com      **主机名

Documentroot /var/www/virtual/news.westos.com/html

Customlog logs/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>

systemctl restart httpd.service   重启服务

在浏览器中访问http://news.westos.com

访问http://news.westos.com自动转到https://news.westos.com

vim news.conf   修改如下:

<Virtualhost *:80>

Servername news.westos.com

RewriteEngine on

RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301] **当访问http时带他访问https

</Virtualhost>

<Directory "/var/www/virtual/news.westos.com/html">

Require all granted

</Directory>

<Virtualhost *:443>

Servername news.westos.com

Documentroot /var/www/virtual/news.westos.com/html

Customlog logs/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>

systemctl restart httpd.service   重启服务

此时在浏览器中访问http://news.westos.com还是https://news.westos.com都自动转到https://news.westos.com

[**php和cgi**]

cd /var/www/html/

ls

vim index.html

vim index.php

1  <?php

2 phpinfo ();

3  ?>

vim /etc/httpd/conf/httpd.conf

163 <IfModule dir_module>

164     DirectoryIndex index.php index.html    优先读取php 确认发布目录是/var/www/html/

systemctl restart httpd.service

yum install php -y      安装

cd /etc/httpd/conf.d/

systemctl restart httpd.service  重启服务

cd /var/www/html/

mkdir cgi        [先建立一个cgi目录]

cd cgi/

yum install httpd-manual   安装manual(查找cgi需要的命令)

vim index.cgi

1 #!/usr/bin/perl

2 print "Content-type: text/html\n\n";

3 print `date`;

perl index.cgi        **测试cgi是否可用

chmod +x index.cgi    **[给一个执行权限,可以用 prel index.cgi]

cd /etc/httpd/conf.d/

vim 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>

systemctl restart httpd.service

ls -Zd cgi-bin/

semanage fcontext -a -t httpd_sys_script_exec_t ‘/var/www/html/cgi(/.*)?‘  修改安全上下文

restorecon -FvvR /var/www/html/cgi/

测试:http://172.25.254.149/cgi/index.cgi

yum install mariadb-server -y             **安装服务

systemctl start mariadb                   **重启服务

vim /etc/my.cnf                    **数据库配置文件

skip-networking=1            **关闭远程连接

systemctl restart mariadb

mysql_secure_installation

cd /var/www/html/

ls

lftp 172.25.254.250             **下载Discuz_X3.2_SC_UTF8.zip软件包

unzip Discuz_X3.2_SC_UTF8.zip   ** 解析

less readme/readme.txt

setenforce 0

chmod 777 upload/ -R

yum install php-mysql.x86_64   下载两者关联的服务

systemctl restart httpd.service

在浏览器中访问http://172.25.254.149/upload/install     **进行设置

[**squit**]

squit正向解析:(效果:通过172.25.49.11浏览器可以访问172.25.254.250)

yum install squid -y                安装服务

vim /etc/squid/squid.conf

56 http_access allow all            允许所有访问

62 cache dir ufs /var/spool/squid 100 16 256

systemctl start squid                开启服务

测试172.25.49.11

打开 firefox  把Advanced——Network中的Settings,Manual ~ 中 写入你所访问的缓冲机(有两块网卡的那个)。

然后访问172.25.254.250,就会成功。虽然 ping 不同 172.25.254.250,但是能访问。

[2.缓存网站信息,并且轮询显示]

yum install squid。

vim /etc/squid/squid.conf

56 http access_allow_all      **允许所有人访问

59 http_port 80 vhost vport   **使用80端口

60 cache_peer 172.25.254.60 parent 80 0no-query originserver round-robin name=   web1

61 cache_peer 172.25.254.4 parent 80 0no-query originserver round-robin name=   web2

62 cache_peer_domain web1web2 www.test.com

63 cache_dir ufs /var/spool/squid 100 16 256   cache_peer_domain web1 web2www.test.com    **设置网站访问域名

systemctl restart squid

并且在/etc/hosts 中添加 172.25.254.149 www.test.com

时间: 2024-08-07 03:23:31

虚拟主机加密与网页重写 squit服务的相关文章

Ubuntu Server 14.04 Apache2.4 虚拟主机配置 以及 模块重写的配置

环境:Ubuntu Server 14.04 Apache2.4 1.虚拟主机配置 在apache2.4中,虚拟主机的目录是通过/etc/apache2/sites-available中配置的,默认情况下,apache有一个默认的虚拟主机文件叫000-default.conf.我们将会复制000-default.conf文件内容到我们新的虚拟主机配置文件中. sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/si

虚拟主机.htaccess伪静态(URL重写)建立多站点

Apache主机一般支持.htaccess伪静态,即可以实现绑定域名到子目录.一个空间多个站点.应用举例:绑定www.qijingling.com到htaccess目录根目录下.htaccess内容 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # 绑定www.qijingling.com到子目录htaccess RewriteCond %{HTTP_HOST} ^www.qijingling.com$ [NC] Rewrite

web服务之httpd虚拟主机配置你造吗?

一.httpd虚拟主机的分类 1.基于ip地址的虚拟主机 2.基于端口的虚拟主机 3.基于域名的虚拟主机 二.配置虚拟主机 实验环境:centos6,使用Yum安装的httpd服务 准备工作:注释中心主机的DocumentRoot站点根目录,创建/etc/httpd/conf.d/vhosts.conf配置文件,创建实验需的站点目录: mkdir -pv /www/{a.com,b.net,c.org}/htdocs,每次修改配合文件时检查语法:httpd -t   重启服务:service h

httpd服务之虚拟主机、访问控制、https配置详解

前言 上文讲解了http协议及httpd的一些特性,是学习web服务需要掌握的一些基础知识,接下来让我们进一步了解httpd相关功能的配置,本文讲解的是虚拟主机,访问控制及https等功能的配置. httpd之虚拟主机 虚拟主机共分为三种模式:基于IP.基于端口.基于主机名(FQDN) 实验环境介绍 开始之前,先介绍一下httpd在CentOS6.6版本及文件: 版本:      httpd-2.2.15(CentOS7升级为2.4系列) 配置文件:         /etc/httpd/con

基于域名虚拟主机及主站迁移

第二章实验(二):基于域名虚拟主机及主站迁移 1.配置BIND支持多域名解析:在实际工作中需要申请多个域名,并做好解析. 登录到192.168.100.100(已经提供了linuxfan.cn的解析) [[email protected] ~]# vim /var/named/chroot/etc/named.conf   ##在该文件末尾添加如下内容 zone "sggfu.com" IN { type master; file "sggfu.com.zone";

nginx生产环境常用功能include 、虚拟主机别名、rewrite、nginx status详细解析

一.配置文件优化之include参数 如果我们用nginx搭建虚拟主机,虚拟主机太多,我们不能把所有配置放置在nginx.conf中吧?那样这个配置文件就太大了,看起来很乱,所有这时就产生了 include参数: 大家如果了解apache软件,就会知道apache主配置包含虚拟主机子文件的方法,其实nginx也借鉴了apache的这种包含方法 nginx的主配置文件为nginx.conf,主配置文件所包含的所有虚拟主机的子配置文件会统一放入extra(这个名字随便起的)目录中,虚拟主机的配置文件

CentOS 7运维管理笔记(6)----Apache 基于 IP 的虚拟主机配置

Apache 配置虚拟主机支持3种方式:基于IP的虚拟主机配置,基于端口的虚拟主机配置,基于域名的虚拟主机配置.本篇随笔记录自己基于IP的虚拟主机配置. 如果同一台服务器有多个IP,可以使用基于IP的虚拟主机配置,将不同的服务绑定在不同的IP上. (1)绑定IP: 在虚拟机中搭建的CentOS 7 服务器的IP被自己设置为了静态IP 192.168.1.210,现在使用ifconfig在同一个网络接口上绑定192.168.1.211~213这三个IP: ifconfig eth0:1 192.1

httpd.2.4虚拟主机配置测试

测试目标: 三个虚拟主机,要求如下 vhost1: phpMyAdmin, 同时提供https服务: vhost2: wordpress 配置过程: 一.配置vhost1 1.首先配置vhost1,先搭建私有CA 在172.16.20.242上搭建私有CA: (1) 创建私钥,公钥无需处理 [[email protected] ~]# cd /etc/pki/CA/ [[email protected] CA]# (umask 077;openssl genrsa -out private/ca

nginx之安装、多虚拟主机、反向代理和负载均衡

一.web服务器与web框架 1.web服务器简介 Web 网络服务是一种被动访问的服务程序,即只有接收到互联网中其他主机发出的请求后才会响应,最终用于提供服务程序的Web服务器会通过 HTTP(超文本传输协议)或 HTTPS(安全超文本传输协议)把请求的内容传送给用户. 目前能够提供 Web 网络服务的程序有 IIS.Nginx 和 Apache 等.其中,IIS(Internet Information Services,互联网信息服务)是Windows系统中默认的Web服务程序Nginx