1、简述HTTP交互原理
浏览器通过域名发送请求,请求到达DNS服务器解析成IP地址到互联网上,浏览器和IP的目的地址进行TCP/IP的三次握手建立TCP连接,浏览器发送的请求有header,有访问的hostname,语言,协议等头部信息
服务器发送response头部,有服务器名称,状态码等信息返回给客户端,数据在body中
传送完后断开连接
2、实现一个Nginx热部署
server{
listen 80;
server_name game.boy.com;
root /code/gameboy;
location / {
index index.html;
}
}
3、搭建一款Wordpress博客系统
【web端】
server{
listen 80;
server_name blog.libro.com;
root /code/wordpress;
location / {
index index.php;
}
location ~ .php$ {
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME
d
o
c
u
m
e
n
t
r
o
o
t
document_root
documentrootfastcgi_script_name;
fastcgi_param HTTPS on;
include fastcgi_params;
}
}
【代理端】
upstream wp_web {
server 172.16.1.7;
server 172.16.1.8;
}
server{
listen 443 ssl;
server_name blog.libro.com;
ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
location / {
proxy_pass http://wp_web;
include proxy_params;
}
}
server {
listen 80;
server_name blog.libro.com;
return 302 https://
s
e
r
v
e
r
n
a
m
e
server_name
servernamerequest_uri;
}
4、简述对称加密与非对称加密
对称加密是一对秘钥都是相同的,加密和解密都用这个秘钥
非对称加密是公钥和私钥,公钥发送给请求方,请求方用公钥对数据加密
私钥自己保留,用来解密请求方发送来的数据,负责解密
5、实现一个keepalive高可用测试
【Master】
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 50
priority 150
advert_int 3
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.100
}
}
【Backup】
global_defs {
router_id lb02
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 50
priority 100
advert_int 3
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.100
}
}
重启keepalived服务即可实现抢占的高可用服务