运维问题解决记录
1.后端两台服务器通过HAProxy代理做高可用,但是访问时出现登陆后session就过期。
-- 这是因为HAProxy未配置session粘连,导致登陆和操作可能落在不同的服务器上。
2.vsftp 不支持 ln 软连接,如何把一个用户的目录给另一个用户访问?
-- 使用mount --bind 有类似效果。
3.Nginx配置允许跨域访问:
在nginx.conf里找到server项,并在里面添加如下配置:
server {
listen 80;
server_name www.example.com;
access_log /data/web_log/nginx_log/example.access.log;
error_log /data/web_log/nginx_log/example.error.log;
client_max_body_size 100m;
location / {
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Max-Age 1728000;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS,PUT,DELETE;
add_header Access-Control-Allow-Headers 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,X-Requested-With';
return 204;
}
if ($http_origin ~* (https?://(.*)(example\.com$))) {
add_header Access-Control-Allow-Origin $http_origin;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS,PUT,DELETE;
add_header Access-Control-Expose-Headers Content-Length,Content-Range;
}
proxy_pass http://192.168.1.111:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
注释如下
第一条指令:授权从example.com的请求(必需)
第二条指令:当该标志为真时,响应于该请求是否可以被暴露(可选)
第三条指令:允许脚本访问的返回头(可选)
第四条指令:指定请求的方法,可以是GET, POST, OPTIONS, PUT, DELETE等(可选)
4.MAC下安装pip:curl https://bootstrap.pypa.io/get-pip.py | python
5.查询本机外网出口IP地址:#curl cip.cc curl ifconfig.me