linux及案例operation运维第二天_第1页
linux及案例operation运维第二天_第2页
linux及案例operation运维第二天_第3页
linux及案例operation运维第二天_第4页
linux及案例operation运维第二天_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

NSDOperationNginx用户认证及控NginxNginxIP05NginxNginxSSLNginx然后客户端页面验证NginxWeb服务器使用火狐浏览器curl图-with-http_stub_status_modulewith-http_ssl_moduletp:SSLuser:group:步骤一:构建Nginx服务器1)nginx[root@svr5~]#yum–yinstallgccpcre-developenssl- [root@svr5~]#useradd–s/sbin/nologin[root@svr5~]#tar-zxvfnginx-[root@svr5~]#cdnginx-[root@svr5nginx-0.8.55]#./configureprefix=/usr/local/nginx user=nginx group=nginx with-http_stub_status_module >--with- ..nginxpathprefix:nginxbinaryfile:nginxconfigurationprefix:nginxconfigurationfile:nginxpidfile:nginxerrorlogfile:nginxhttpaccesslogfile:nginxhttprequestbodytemporaryfiles:"nginx temporaryfiles:"nginxhttpfastcgitemporaryfiles:nginxhttpuwsgitemporaryfiles:nginxhttpscgitemporaryfiles:[root@svr5nginx-0.8.55]#make&&makeinstall 2)nginx[root@svr5~]#/usr/local/nginx/sbin/nginx–c/usr/local/nginx/conf/nginx.confnginx服务默认通过TCP80端口客户端请求:[root@svr5~]#netstat-anptu|grep 0 3)NginxWebNginxWeb服务默认首页文档为/usr/local/nginx/html/,在 index.html[root@svr5~]#cat eto<bodybgcolor="white" eto[root@svr5~]#tar-zxvfnginx-[root@svr5~]#cdnginx-[root@svr5nginx-1.0.5]#./configure>--prefix=/usr/local/nginx>--user=nginx>--group=nginx>--with-http_stub_status_module>--with-[root@svr5nginx-1.0.5]#[root@svr5nginx-1.0.5]#cd[root@svr5sbin]#mvnginx [root@svr5sbin]#cd/root/nginx-[root@svr5objs]#cpnginx [root@svr5objs]#cd/root/nginx-[root@svr5nginx-1.0.5]#make /usr/local/nginx/sbin/nginx-nginx:theconfigurationfile/usr/local/nginx/conf/nginx.confsyntaxisnginx:configurationfile/usr/local/nginx/conf/nginx.conftestiskill-USR2`catsleeptest-fkill-QUIT`cat[root@svr5~]#/usr/local/nginx/sbin/nginx 步骤二:客户 测用户认证及控沿用 Web用户名为:tom,为 下首页文档所有主机均可以为创建二 /test,并生成index.html文 index.html05通过Nginx实现Web页面的认证与控制,需要修改Nginx配置文件,在location容器中添加allow及deny语句实现控制,添加auth语句实现用户认证。最后使用htpasswd命令创建用户及密Nginx修改[root@pc205~]#vim..serverlistenserver_nameauth_basic"Input auth_basic_user_file //认证文location/rootindexindex.html}location/testallow deny //所indexindex.html} [root@svr5~]#mkdir[root@svr5~]#echo“test”>[root@svr5~]#htpasswd-c/usr/local/nginx/conf/pass.txtNewRe-typenewAddingpasswordforuser[root@svr5~]#/usr/local/nginx/sbin/nginx–s[root@svr5~]#[root@svr5~]#firefox//输入后可[root@svr5~]#firefox//输入后可以 ~]#firefox//输入后可以[root@~]#firefox//输入后无实现两个基于的虚拟主机,分别 的Web服务仅允许05对 的站点进行用户认证,用户名称为tom,为对 的站点进行SSL加修改Nginx配置文件,添加server容器实现虚拟主机功能;对于需要进行控制的虚拟主机添allowdenyauthSSLssl[root@svr5~]#vim..serverlisten allow deny //所auth_basic"Input auth_basic_user_file //认证文location/root //指定根路indexindex.html}}serverlisten ssl_ //指定文ssl_ ssl_session_timeoutssl_protocolsSSLv2SSLv3ssl_ciphersssl_prefer_server_cipherslocation/root //指定根路indexindex.html}}[root@svr5~]#opensslgenrsaoutcert.key [root@svr5~]#opensslreqnewx509keycert.keyoutcert.pem[root@svr5~]#cp{cert.key,cert.pem}/usr/local/nginx/conf [root@svr5~]#mkdir[root@svr5~]#echo“www”>[root@svr5~]#echo“bbs”/usr/local/nginx/bbs/index.html4)nginx[root@svr5~]#/usr/local/nginx/sbin/nginx–s[root@svr5~]#[root@svr5~]#vim[root@svr5~]#firefox //输入后可[root@svr5~]#firefox //信任后可[root@~]#firefox //无 ~]#firefox WebhttpdNginxWebWeb2,30使用3台RHEL6虚拟机,其中一台作为Nginx服务器,该服务器需要配置两块网卡,IP地址分54,WebIP05图-[root@svr5~]#vim..http..upstreamwebserverserver05weight=2max_fails=2server00weight=1max_fails=2}..server location/_pass15.16.[root@svr5~]#/usr/local/nginx/sbin/nginx–s[root@svr5~]#WebyumhttpdWeb[root@svr5~]#yum-yinst

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论