Nextcloud报错 Error transferring /login/v2/poll – server replied: Bad Request

目录 文章

Windows 10 nextcloud客户端连接登录时出啊下以下报错:

访问“token”端点时出错:
Error transferring https://www.orcy.net.cn:12345/login/v2/poll - server replied: Bad Request

解决办法:

1.卸载Windows上安装的nextcloud客户端,重新下载安装,或者更换一下其他版本尝试。

大部分出现此问题的案例可以使用此方法解决

2.检查配置文件

vi config.php

查看是否有以下内容

  'overwrite.cli.url' => 'https://www.orcy.net.cn',
  'overwriteprotocol' => 'https',

如果没有以上内容,请在配置文件添加,重载web服务器配置或者重启后再次尝试

3.nextcloud服务在反向代理后

请修改nginx反代服务器设置,添加以下内容

proxy_set_header Host $http_host;
#I use this to prevent port change on redirect
#alternatively use the common
#proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
#this preserves the initial protocol, the https…

官方文档相关说明

Login flow v2

While the login flow works very nice in a lot of cases there are especially on dekstop application certain hurdles. Special proxy configuration, client side certificates and the likes can cause trouble. To solve this we have come up with a second login flow that uses the users default webbrowser to authenticate. Thus ensuring that if they can login via the web they can also login in the client.

To initiate a login do an anonymous POST request

curl -X POST https://cloud.example.com/index.php/login/v2

This will return a json object like

{
    "poll":{
        "token":"mQUYQdffOSAMJYtm8pVpkOsVqXt5hglnuSpO5EMbgJMNEPFGaiDe8OUjvrJ2WcYcBSLgqynu9jaPFvZHMl83ybMvp6aDIDARjTFIBpRWod6p32fL9LIpIStvc6k8Wrs1",
        "endpoint":"https:\/\/cloud.example.com\/login\/v2\/poll"
    },
    "login":"https:\/\/cloud.example.com\/login\/v2\/flow\/guyjGtcKPTKCi4epIRIupIexgJ8wNInMFSfHabACRPZUkmEaWZSM54bFkFuzWksbps7jmTFQjeskLpyJXyhpHlgK8sZBn9HXLXjohIx5iXgJKdOkkZTYCzUWHlsg3YFg"
}

The url in login should be opened in the default browser, this is where the user will follow the login procedure. The program should directly start polling the poll endpoint:

curl -X POST https://cloud.example.com/login/v2/poll -d "token=mQUYQdffOSAMJYtm8pVpkOsVqXt5hglnuSpO5EMbgJMNEPFGaiDe8OUjvrJ2WcYcBSLgqynu9jaPFvZHMl83ybMvp6aDIDARjTFIBpRWod6p32fL9LIpIStvc6k8Wrs1"

This will return a 404 until authentication is done. Once a 200 is returned it is another json object.

{
    "server":"https:\/\/cloud.example.com",
    "loginName":"username",
    "appPassword":"yKTVA4zgxjfivy52WqD8kW3M2pKGQr6srmUXMipRdunxjPFripJn0GMfmtNOqOolYSuJ6sCN"
}

Use the server and the provided credentials to connect. Note that the 200 will only be returned once.

Linux下提示命令找不到:bash:command not found

目录 文章

Linux下输入某些命令时会提示:bash:command not found

首先,查看$PATH中是否包含了这些命令

$PATH:决定了shell到哪些目录中去寻找命令或程序,PATH值是一系列的目录。当运行程序时,linux到这些目录下搜索进行编译链接。

格式:

PATH = $PATH:<PATH1>:<PATH2>:<PATH3>:...:<PATH N>

可以将自己指定的路径加到PATH中,中间用冒号”:”隔开。环境变量更改后,会在用户下次登录的时候生效;若想立即生效,则需要执行:

 $ source .bash_profile

完成之后可以通过 echo PATH查看当前的搜索路径。这样定制之后,可以避免频繁的启动位于shell搜索路径之外的程序

查看PATH值:

方法一:export

[root@localhost ~]# export
declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/0/bus"
declare -x HISTCONTROL="ignoredups"
declare -x HISTSIZE="1000"
declare -x HOME="/root"
declare -x HOSTNAME="localhost.localdomain"
declare -x LANG="en_US.UTF-8"
declare -x LESSOPEN="||/usr/bin/lesspipe.sh %s"
declare -x LOGNAME="root"
declare -x LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.m4a=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.oga=01;36:*.opus=01;36:*.spx=01;36:*.xspf=01;36:"
declare -x MAIL="/var/spool/mail/root"
declare -x OLDPWD
declare -x PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
declare -x PWD="/root"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x SSH_CLIENT="192.168.147.1 57795 22"
declare -x SSH_CONNECTION="192.168.147.1 57795 192.168.147.128 22"
declare -x SSH_TTY="/dev/pts/0"
declare -x TERM="linux"
declare -x USER="root"
declare -x XDG_RUNTIME_DIR="/run/user/0"
declare -x XDG_SESSION_ID="19"
[root@localhost ~]# 

方法二: echo $PATH

[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# 

添加$PATH环境变量:

[root@localhost u-boot-sh4]#export PATH=/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH

再次查看:

[root@localhost u-boot-sh4]# echo $PATH
/opt/STM/STLinux-2.3/devkit/sh4/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

则说明添加PATH成功

上述方法添加PATH在终端关闭后会消失。建议通过编辑/etc/profile 修改PATH,也可修改/home目录下的 .bashrc

[root@localhost ~]# vi /etc/profile 
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.

pathmunge () {
    case ":${PATH}:" in
        *:"$1":*)
            ;;
        *)
            if [ "$2" = "after" ] ; then
                PATH=$PATH:$1
            else
                PATH=$1:$PATH
            fi
    esac
}


if [ -x /usr/bin/id ]; then
    if [ -z "$EUID" ]; then
        # ksh workaround
        EUID=`id -u`
        UID=`id -ru`
    fi
    USER="`id -un`"
    LOGNAME=$USER
    MAIL="/var/spool/mail/$USER"
fi

# Path manipulation
if [ "$EUID" = "0" ]; then
    pathmunge /usr/sbin
    pathmunge /usr/local/sbin
else
    pathmunge /usr/local/sbin after
    pathmunge /usr/sbin after
fi

HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
else
    export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

# By default, we want umask to get set. This sets it for login shell
"/etc/profile" 76L, 1750C

在最后添加:

export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH"

保存后,退出,执行:

[root@localhost etc]#source /etc/profile

$PATH下目录简介

PATH中主要有以下四个目录:

/bin, /usr/bin, /sbin, /usr/sbin

主要存放的东西:

./bin:

bin为binary的简写主要放置一些系统的必备执行档案。如:cat,cp, chmod df, dmesg, gzip, kill, ls, mkdir, more, mount, rm, su, tar 等。

/usr/bin:

主要放置一些应用软体工具的必备执行档例。如:c++、g++、gcc、chdrv、diff、dig、du、eject、elm、free、gnome、 gzip、htpasswd、kfm、ktop、last、less、locale、m4、make、man、mcopy、ncftp、 newaliases、nslookup passwd、quota、smb、wget等。

/sbin:

主要放置一些系统管理的必备程式例。如:cfdisk、dhcpcd、dump、e2fsck、fdisk、halt、ifconfig、ifup、 ifdown、init、insmod、lilo、lsmod、mke2fs、modprobe、quotacheck、reboot、rmmod、 runlevel、shutdown等。

/usr/sbin:

放置一些网路管理的必备程式例。如:dhcpd、httpd、imap、in.*d、inetd、lpd、named、netconfig、nmbd、samba、sendmail、squid、swap、tcpd、tcpdump等。

Linux下使用mail命令发送邮件

目录 文章

Linux下的mail命令可以方便,快速的完成发送邮件。下面以CentOS为例:

1.安装

[root@vm8028 ~]# mail
-bash: mail: command not found
[root@vm8028 ~]# yum install mailx -y

2.配置

vi /etc/mail.rc

在文件尾加上如下配置

set from=support@orcy.net.cn
set smtp=smtp.orcy.net.cn
set smtp-auth-user=support@orcy.net.cn
set smtp-auth-password=**邮箱密码**
set smtp-auth=login

注:set fromset smtp等后边不要加入空格

3.发送邮件测试

echo "Content" | mail -s "Title" kissyou@love.com

4.其他

mail命令可以使用 mail --h 查看具体更多的使用方法

无邮件正文

mail -s "Title"  kissyou@love.com

有邮件正文

mail -s "Tile"  kissyou@love.com < /root/sms_out.txt 

或者 cat /root/sms.txt  | mail -s "Tile"  kissyou@love.com
或者 echo “”Content“  |   mail -s "Tile"  kissyou@love.com

带附件的邮件

 mail -s "Tile"  kissyou@love.com  -a  /root/sms.txt