system administration nfs & web servers. nfs server

35
System Administration NFS & Web Servers

Upload: cecil-strickland

Post on 26-Dec-2015

294 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: System Administration NFS & Web Servers. NFS SERVER

System AdministrationNFS & Web Servers

Page 2: System Administration NFS & Web Servers. NFS SERVER

NFS SERVER

Page 3: System Administration NFS & Web Servers. NFS SERVER

File System OperationsCreate file / directoryRemove file / directoryList directoryOpen fileRead from fileWrite to file…

Page 4: System Administration NFS & Web Servers. NFS SERVER

NFSNetwork file systemFile system ops over networkRPC-basedIP-based authorizationTraffic not encrypted

Page 5: System Administration NFS & Web Servers. NFS SERVER

From 鳥哥的 Linux 私房菜

Page 6: System Administration NFS & Web Servers. NFS SERVER

Remote Procedure Call

From SGI IRIX Network Programming Guide

Page 7: System Administration NFS & Web Servers. NFS SERVER

RPC – Port mapperList which port

has what service“portmap” or

“rpcbind”List services:

rpcinfo -p

Page 8: System Administration NFS & Web Servers. NFS SERVER

NFS ServerDebian Package: nfs-kernel-

server◦NFS server is implemented in kernel.

The package is for support utilities.Configuration: /etc/exports

◦See exports(5) manpageShow exported paths

◦exportfs◦showmount

Page 9: System Administration NFS & Web Servers. NFS SERVER

/etc/exports

/home 192.168.1.0/24(ro)Path Client IP (modifier)目錄 分享對象 ( 權限 )

Page 10: System Administration NFS & Web Servers. NFS SERVER

Client IPsIPs (192.168.1.1)IP networks (192.168.1.0/24)Hostnames

(www.csie.ntu.edu.tw)Wildcards (*.csie.ntu.edu.tw)

◦Hostname determined via reverse DNS lookup

Page 11: System Administration NFS & Web Servers. NFS SERVER

Modifiersrw / rosync / asyncroot_squash / no_root_squash

◦all_squash[more in exports(5) manpage]

Page 12: System Administration NFS & Web Servers. NFS SERVER

NFS ClientDebian Package: nfs-common

◦NFS client is implemented in kernel.The package is for support utilities.

Configuration: /etc/fstab

Page 13: System Administration NFS & Web Servers. NFS SERVER

/etc/fstab

# local/dev/sda1 / ext4 rw# nfsnfs:/home /home nfs rw

Page 14: System Administration NFS & Web Servers. NFS SERVER

NFS mount optionsfg / bghard / softintr / nointr (No use after 2.6.25)rsize= & wsize=See nfs(5) manpage

Page 15: System Administration NFS & Web Servers. NFS SERVER

AutomountAutomatically mount filesystem

when accessed◦Unmount after some time unused

Implemented in kernelPackage: autofs , autofs5

Page 16: System Administration NFS & Web Servers. NFS SERVER

WEB SERVERS

Page 17: System Administration NFS & Web Servers. NFS SERVER

HTTPHypertext Transfer Protocol

Request

ResponseHeader

ResponseBody

Page 18: System Administration NFS & Web Servers. NFS SERVER

HTTP (cont.)Other binary protocols exist

◦SPDY Multiplexing streams through a single TCP

connection.

◦QUIC Optimized for mobile devices Over UDP SSL handshake improvement

Page 19: System Administration NFS & Web Servers. NFS SERVER

Apache HTTP ServerOldest(?) open source web serverMost popular according to

NetcraftVery versatile

◦CGI/FastCGI/WSGI/PSGI/Rack/…◦mod_perl / mod_python / mod_ruby◦Many 3rd party modules

Page 20: System Administration NFS & Web Servers. NFS SERVER

LighttpdLightweight HTTP(S) serverSingle process event driven

◦Early solution to C10k problemCGI, FastCGI, SCGI supportLittle new development

Page 21: System Administration NFS & Web Servers. NFS SERVER

NginxWeb serverReverse proxyLoad balancingSingle process event drivenFastCGI / SCGI / uWSGINo CGIHigh performance static file

serving

Page 22: System Administration NFS & Web Servers. NFS SERVER

Multi-Processing Moduleprefork

◦1 process per requestworker

◦worker thread pool◦1 thread per connection

Event◦event driven with worker thread pool◦1 thread per request

More info see◦http://

serverfault.com/questions/383526/how-do-i-select-which-apache-mpm-to-use

Page 23: System Administration NFS & Web Servers. NFS SERVER

Apache PackagesDebian meta-package

◦apache2MPM

◦apache2-mpm-*3rd party modules

◦libapache2-mod-*

Page 24: System Administration NFS & Web Servers. NFS SERVER

Basic Configuration# What port to use

Listen 80

# My name

ServerName nasa.csie.ntu.edu.tw

# Run as

User www-data

Group www-data

# PID

PidFile /var/run/apache2.pid

# log

ErrorLog /var/log/apache2/error.log

Page 25: System Administration NFS & Web Servers. NFS SERVER

Serving Configuration# Where is /

DocumentRoot /var/www/base

# Permissions for /var/www/base

<Directory /var/www/base>

Options None

Order allow,deny

Allow from all

</Directory>

Page 26: System Administration NFS & Web Servers. NFS SERVER

Virtual HostsServing many sites with 1 serverIP-based virtual hosts

◦1 website per IPPort-based virtual hosts

◦1 website per portName-based virtual hosts

◦Many websites per IP/port◦Differentiate with “Host” header

Page 27: System Administration NFS & Web Servers. NFS SERVER

Name-based Virtual HostNameVirtualHost *

<VirtualHost *>

DocumentRoot /var/www/www

ServerName www.csie.ntu.edu.tw

<Directory /var/www/www>

Options None

Order allow,deny

Allow from all

</Directory>

</VirtualHost>

Page 28: System Administration NFS & Web Servers. NFS SERVER

HTTP Authentication401 Unauthorized

◦Basic Password sent in plaintext

◦Digest Challenge / Response

mod_auth◦mod_auth*◦Many backends

htpasswd◦Manage Apache basic password files

Page 29: System Administration NFS & Web Servers. NFS SERVER

HTTP Authentication<Location /locked>

# Use basic authentication

AuthType Basic

# Name to show in dialog

AuthName “Restricted”

# Use htpasswd file based

AuthBasicProvider file

# Path to password file

AuthUserFile /etc/apache/users.pw

# Any user is good

Require valid-user

</Location>

Page 30: System Administration NFS & Web Servers. NFS SERVER

URL RewriteRewrite a URL internally

◦Make pretty URLs to user◦Map old URL to new

RedirectRegexConditional

Enable mod_rewrite

Page 31: System Administration NFS & Web Servers. NFS SERVER

URL Rewrite# Load mod_rewrite

LoadModule rewrite_module modules/mod_rewrite.so

# Enable rewrite

RewriteEngine On

# rewrite rule

# Redirect /blog?p=N to /new/blog/N

RewriteRule ^/blog?p=(\d+) /new/blog/$1 [R]

Page 32: System Administration NFS & Web Servers. NFS SERVER

FastCGI2.2: mod_fastcgi or mod_fcgid2.4: mod_proxy, mod_proxy_fcgiRun PHP with FastCGI if you can

◦php-fpm – FastCGI Process Manager

Page 33: System Administration NFS & Web Servers. NFS SERVER

PHP FastCGI for Apache 2.2# Load modules

LoadModule fastcgi_module modules/mod_fastcgi.so

# Associate an alias for the 'fake' fcgi call.

Alias /php5.fcgi /var/www/php5.fcgi

# Assign the 'fake' fcgi to an 'external' FastCGI Server

FastCGIExternalServer /var/www/php5.fcgi -flush -host 127.0.0.1:9000

# Create the handler mappings to associate PHP files with a call to '/php5.fcgi'

AddType application/x-httpd-fastphp5 .php

Action application/x-httpd-fastphp5 /php5.fcgi

Page 34: System Administration NFS & Web Servers. NFS SERVER

PHP FastCGI for Apache 2.4

# Load modules

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

# Pass PHP file to FastCGI handler

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/$1

Page 35: System Administration NFS & Web Servers. NFS SERVER

Homework1. Explain the “secure/insecure” options in

/etc/exports in you own words.2. What security issues may incur when using

“insecure” option?3. In early times, running a website over SSL

requires a dedicated IP address. Describe why and how it is solved by using SNI (Server Name Indication).

4. Describe what “TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384” in TLS 1.2 cipher suite means.