运维 cheat sheet

创建用户

useradd username 
password username # 修改用户名密码

给新建用户添加 sudo 权限

visudo

然后像下面一样,在 root ALL=(ALL) ALL 后添加配置

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
username   ALL=(ALL)       ALL

Nginx

Centos 7

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx

编辑 nginx 配置

vim /etc/nginx/nginx.conf

退出卡死的 ssh

先回车,然后输入 “~.”

➜  ~ man ssh

     A single tilde character can be sent as ~~ or by following the tilde by a character other than those described
     below.  The escape character must always follow a newline to be interpreted as special.  The escape character
     can be changed in configuration files using the EscapeChar configuration directive or on the command line by the
     -e option.

     The supported escapes (assuming the default ‘~’) are:

     ~.      Disconnect.

vim 保存时 获得 root 权限

w !sudo tee %

Nginx 配置 socket.io websocket



 upstream socket_nodes{
        server 127.0.0.1:3002;
        keepalive 15;
    }


server {
        listen 80;
        server_name api.domain.com;

        location /location/api {
                proxy_pass http://127.0.0.1:3001;
        }

        location /socket.io/ {
                # 设定正确的header
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        # nginx 1.13版本以上,支持websocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        proxy_redirect off;

        proxy_pass http://socket_nodes;
        }
     }

你可能感兴趣的:(运维 cheat sheet)