云溪的 blog
  • Archive
  • Media
  • Search
  • Tags
  • About
Home

Posts

centos 搭建 NFS

查看系统是否已安装NFS $ rpm -qa | grep nfs nfs-utils-lib-1.1.5-13.el6.i686 nfs-utils-1.2.3-78.el6_10.1.i686 如果没有安装,执行下面命令 $ yum -y install nfs-utils rpcbind NFS配置文件 NFS的常用目录 /etc/exports NFS服务的主要配置文件 /usr/sbin/exportfs NFS服务的管理命令 /usr/sbin/showmount 客户端的查看命令 /var/lib/nfs/etab 记录NFS分享出来的目录的完整权限设定值 /var/lib/nfs/xtab 记录曾经登录过的客户端信息 配置 NFS 服务 NFS服务的配置文件为 /etc/exports,这个文件是NFS的主要配置文件,不过系统并没有默认值,所以这个文件不一定会存在,可能要使用vim手动建立,然后在文件里面写入配置内容。 /etc/exports文件内容格式: 客户端1 选项(访问权限,用户映射,其他) 客户端2 选项(访问权限,用户映射,其他) 例如 $ vim /etc/exports 写入下列语句 /home/data your_ssl_server_ip/24(rw,sync,no_root_squash) 常用配置项说明: 访问权限选项 设置输出目录只读:ro 设置输出目录读写:rw 用户映射选项 all_squash:将远程访问的所有普通用户及所属组都映射为匿名用户或用户组(nfsnobody); no_all_squash:与all_squash取反(默认设置); root_squash:将root用户及所属组都映射为匿名用户或用户组(默认设置); no_root_squash:与rootsquash取反; anonuid=xxx:将远程访问的所有用户都映射为匿名用户,并指定该用户为本地用户(UID=xxx); anongid=xxx:将远程访问的所有用户组都映射为匿名用户组账户,并指定该匿名用户组账户为本地用户组账户(GID=xxx); 其它选项: secure:限制客户端只能从小于1024的tcp/ip端口连接nfs服务器(默认设置); insecure:允许客户端从大于1024的tcp/ip端口连接服务器; sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性; async:将数据先保存在内存缓冲区中,必要时才写入磁盘; wdelay:检查是否有相关的写操作,如果有则将这些写操作一起执行,这样可以提高效率(默认设置); no_wdelay:若有写操作则立即执行,应与sync配合使用; subtree:若输出目录是一个子目录,则nfs服务器将检查其父目录的权限(默认设置); no_subtree:即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率; 设置防火墙 $ sudo vim /etc/sysconfig/iptables 加入下面两句 -A INPUT -p tcp -s your_client_ip/32 --dport 1:65535 -j ACCEPT -A INPUT -p udp -s your_client_ip/32 --dport 1:65535 -j ACCEPT 向客户端开放所有端口(因为 NSF 端口是随机监听的所以需要对客户端开放所有端口) 重启 NFS 服务 注意重启顺序需要严格按照下面执行 ...

August 4, 2019 · 1 min · 云溪

解决nfs挂载错误wrong fs type, bad option, bad superblock

[root@localhost]# mount -t nfs 192.168.0.106:/home/nfs1 mount: wrong fs type, bad option, bad superblock on 192.168.0.106:/home/nfs1, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program) In some cases useful info is found in syslog - try dmesg | tail or so 解决办法: apt-get install nfs-common 或者 yum install nfs-utils

August 3, 2019 · 1 min · 云溪

申请 let's encrypt 通配符 ssl 证书

在<使用 let’s encrypt 为网站开启 https>一问中,讲述了,如何用 let’s encrypt 为网站开启 https 协议,这篇内容讲一下如何申请 let’s encrypt 通配符证书 什么是通配符证书 通配符 SSL 可以保护网站的 URL 及其所有子域(数量不限)。例如,一个单独的通配符证书就可以保护 www.artacode.com、blog.artacode.com 和 store.artacode.com。 通配符证书可以保护通用域名和您在提交申请时指定的级别下的所有子域。只需在通用域名左侧的子域区域添加星号 (*) 即可。 举例 如果为 *.artacode.com 申请证书,则可以保护: artacode.com www.artacode.com photos.artacode.com blog.artacode.com 如果为 *.www.artacode.com 申请证书,则可以保护: www.artacode.com mail.www.artacode.com photos.www.artacode.com blog.www.artacode.com 通配符证书可以像常规 SSL 证书一样为网站提供保护,并且申请是使用同一种验证方法进行处理的。不过,一些 Web 服务器可能要求使用通配符证书的每个子域都有唯一的 IP 地址。 如何申请 let’s encrypt 通配符证书 安装 Certbot $ wget https://dl.eff.org/certbot-auto $ sudo mv certbot-auto /usr/local/bin/certbot-auto $ sudo chown root /usr/local/bin/certbot-auto $ sudo chmod 0755 /usr/local/bin/certbot-auto 申请证书 certbot-auto --server https://acme-v02.api.letsencrypt.org/directory -d "*.artacode.com" -d "artacode.com" --manual --preferred-challenges dns-01 certonly //这里多加了一个 `-d "artacode.com"` 是因为 `-d "*.artacode.com"` 不包含 artacode.com 1. 填写接受通知的邮箱 Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator manual, Installer None Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): test@test.com 2. 同意协议 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: (A)gree/(C)ancel: a 3. 同意证书服务器记录本机IP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NOTE: The IP of this machine will be publicly logged as having requested this certificate. If you're running certbot in manual mode on a machine that is not your server, please ensure you're okay with that. Are you OK with your IP being logged? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4. 设置域名解析 Please deploy a DNS TXT record under the name _acme-challenge.artacode.cn with the following value: xxxxxxxxxxxxxx Before continuing, verify the record is deployed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Press Enter to Continue 回车继续 5. 生成证书成功 Waiting for verification... Cleaning up challenges IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/artacode.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/artacode.com/privkey.pem Your cert will expire on 2019-11-01. To obtain a new or tweaked version of this certificate in the future, simply run certbot-auto again. To non-interactively renew *all* of your certificates, run "certbot-auto renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le 配置 Nginx server { server_name xx.artacode.com; listen 443 http2 ssl; ssl_certificate /path/.acme.sh/domain/fullchain.cer; ssl_certificate_key /path/.acme.sh/domain/domain.key; ssl_trusted_certificate /path/.acme.sh/domain/ca.cer; } 总结 除了上述方法之外也有一些自动生成的脚本比如acme,就是在 github start 挺多的一个项目,除了手动申请之外也可以借助脚本快速申请 ssl 通配符证书. ...

August 3, 2019 · 3 min · 云溪

使用 let's encrypt 为网站开启 https

启用可用通道 $ yum -y install yum-utils $ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional 安装 Certbot $ sudo yum install certbot python2-certbot-nginx 获取 nginx 服务器证书 $ sudo certbot certonly --nginx 遇到问题 certbot 未找到 nginx 二进制文件 The nginx plugin is not working; there may be problems with your existing configuration. The error was: NoInstallationError(“Could not find a usable ’nginx’ binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.”,) 由于我机器之前机器上已经安装 nginx 安装目录为 /usr/local/nginx/sbin/nginx 而 certbot 默认会到 /usr/bin/nginx 目录下找,因此需要建立一个软连接 ...

July 30, 2019 · 1 min · 云溪

跨域详解  [draft]

什么是跨域 当前页面url 被请求页面url 是否跨域 原因 http://www.test.com/ http://www.test.com/index.html 否 同源(协议、域名、端口号相同) http://www.test.com/ https://www.test.com/index.html 跨域 协议不同(http/https) http://www.test.com/ http://www.google.com/ 跨域 主域名不同(test/google) http://www.test.com/ http://blog.test.com/ 跨域 子域名不同(www/blog) http://www.test.com:8080/ http://www.test.com:7001/ 跨域 端口号不同(8080/7001) #为什么会出现跨域问题 出于浏览器的同源策略限制。同源策略(Sameoriginpolicy)是一种约定,它是浏览器最核心也最基本的安全功能,如果缺少了同源策略,则浏览器的正常功能可能都会受到影响。可以说Web是构建在同源策略基础之上的,浏览器只是针对同源策略的一种实现。同源策略会阻止一个域的javascript脚本和另外一个域的内容进行交互。所谓同源(即指在同一个域)就是两个页面具有相同的协议(protocol),主机(host)和端口号(port) 非同源限制 无法读取非同源网页的 Cookie、LocalStorage 和 IndexedDB 无法接触非同源网页的 DOM 无法向非同源地址发送 AJAX 请求 跨域的解决方案 jsonp JSONP 不是 JSON,它是跨域访问的一种机制。那么什么是跨域访问?什么是 JSONP?如果你不清楚的话,不妨点开看看吧。

July 27, 2019 · 1 min · 云溪
« Prev  Next  »
© 2025 云溪的 blog