运维问题解决记录

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

转载于:https://www.cnblogs.com/chmyee/p/10572914.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值