• No results found

Services: Apache a patchy web server

N/A
N/A
Protected

Academic year: 2021

Share "Services: Apache a patchy web server"

Copied!
21
0
0

Loading.... (view fulltext now)

Full text

(1)

© David Morgan 2003-15

Services: Apache

Services: Apache

a patchy web server

a patchy web server

David Morgan

The Whole Business

The Whole Business

“…the whole business of a web server is to translate a URL either into a filename, and then send that file back over the Internet, or into a program name, and then run that program and send its output back. That is the meat of what it does: all the rest is trimming.”

(2)

© David Morgan 2003-15

A Web Site = a Directory

A Web Site = a Directory

 fedora default: /var/www

 holds “what to send” to connecting clients

– content of files in: /var/www/html, or

– output of programs in: /var/www/cgi-bin

FILE CONTENT

(3)

© David Morgan 2003-15

4 important directories

4 important directories

 For HTML scripts /var/www/html  For programs /var/www/cgi-bin  For config files /etc/httpd/conf

 For logs /etc/httpd/logs -> /var/log/httpd

Default directories and files

Default directories and files

etc httpd var / html cgi-bin error www manual

httpd.conf noindex.html index.html

conf logs your webpage files your executables access_log error_log DocumentRoot ServerRoot

(4)

© David Morgan 2003-15

FILE CONTENT

Subliminal message

PROGRAM OUTPUT

Placeholder default test page

Placeholder default test page

 /var/www/error/noindex.html

 appears as long as administrator supplies no /var/www/html/index.html

(5)

© David Morgan 2003-15

Apache manual

Apache manual

 /var/www/manual/  installed by default

Primary

Primary

config

config

file:

file:

httpd.conf

httpd.conf

 Houses “directives”

 Categorized

– global directives – apache process – default host directives– main “site”

– virtual host directives – other (2nd, 3rd, …) sites

(6)

© David Morgan 2003-15

Turning services on and off

Turning services on and off

 Services re-read configuration files when

restarted

 Starting

– /etc/rc.d/init.d/<script for service> start or

service <script for service> start

 Stopping

– /etc/rc.d/init.d/<script for service> stop or

service <script for service> stop

Turning apache on and off

Turning apache on and off

 Re-reads /etc/httpd/conf/httpd.conf when restarted  Starting

– /etc/rc.d/init.d/httpd start or

service httpd start ( now, “systemctl start httpd.service” )

 Stopping

– /etc/rc.d/init.d/httpd stop or

(7)

© David Morgan 2003-15

Running programs

Running programs

-

-

CGI

CGI

 A way to get a “page,” to send to a client  Alternative to getting it out of a file (“.htm”)  Instead call a program to generate it

 Write the program to output webpage-legal

stuff

 CGI stands for “common gateway interface”

FILE CONTENT

Subliminal message

(8)

© David Morgan 2003-15

Running a CGI program

Running a CGI program

 put the program file in /var/www/cgi-bin

 apache interprets files in cgi-bin as

“runnables”

 run by naming its URL in

1. “location/address” in client/browser directly, or 2. ACTION=<url> within an HTML FORM

construct

Running directly from a browser

Running directly from a browser

names it explicitly

(9)

© David Morgan 2003-15

Running from a form

Running from a form

(haiku.html(haiku.html))

<html> <body> <center>

<form action=/cgi-bin/haiku>

Press the button to invoke the action. The action is to run the "haiku" script.</br></br> <input type=submit value="get haiku here">

</form> </center> </body> </html> htm l for m c o nst ru ct html button

call/perform this action

when user presses this button

Form

Response to form, when button pressed

Running from a form

(10)

© David Morgan 2003-15

Virtual (multiple) servers

Virtual (multiple) servers

 IP-based

– separate IP address for each virtual server

 Name-based

– just one address for all virtual servers

IP

IP

-

-

based: multiple IP addresses

based: multiple IP addresses

 multiple physical interfaces, each with its

own IP

– replicate everything, or

 multiple “ip aliases” on a single physical

interface

(11)

© David Morgan 2003-15

IP

IP

-

-

based: number of daemons

based: number of daemons

 Multiple daemons

– allows separate configurations – performance-expensive

 Single daemon

– must share single configuration – performance-efficient

IP

IP

-

-

based virtual servers

based virtual servers

<VirtualHost www.smallco.com> ServerAdmin webmaster@mail.smallco.com DocumentRoot /groups/smallco/www ServerName www.smallco.com ErrorLog /groups/smallco/logs/error_log TransferLog /groups/smallco/logs/access_log </VirtualHost> <VirtualHost www.baygroup.org> ServerAdmin webmaster@mail.baygroup.org DocumentRoot /groups/baygroup/www ServerName www.baygroup.org ErrorLog /groups/baygroup/logs/error_log TransferLog /groups/baygroup/logs/access_log </VirtualHost>

(12)

© David Morgan 2003-15

IP

IP

-

-

based virtual servers

based virtual servers

 Requires distinct name resolution

– www.smallco.com  111.22.33.44 – www.baygroup.org  111.22.33.45

 Both addresses for the webserver machine

 Apache differentiates by address

 Destination address embedded in IP header

Name

Name

-

-

based virtual servers

based virtual servers

NameVirtualHost 111.22.33.44 <VirtualHost 111.22.33.44> ServerName www.domain.tld DocumentRoot /www/domain </VirtualHost> <VirtualHost 111.22.33.44> ServerName www.otherdomain.tld DocumentRoot /www/otherdomain

(13)

© David Morgan 2003-15

Name

Name

-

-

based virtual servers

based virtual servers

 Requires common name resolution

– www.domain.tld  111.22.33.44 – www.otherdomain.tld  111.22.33.44

 Apache differentiates by name

 Destination name embedded in HTTP request

Differentiation by name

Differentiation by name

Destination domain name embedded in HTTP request

(14)

© David Morgan 2003-15

Differentiation by name

Differentiation by name

Some noteworthy directives

Some noteworthy directives

 Global – ServerRoot – Listen  Host – User, Group – ServerAdmin – ServerName – DocumentRoot – UserDir – DirectoryIndex

(15)

© David Morgan 2003-15

ServerRoot

ServerRoot

# ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept.

#

ServerRoot "/etc/httpd"

from /etc/httpd/conf/httpd.conf

Listen

Listen

# Listen: Allows you to bind Apache to specific IP addresses and/or # ports, in addition to the default. See also the <VirtualHost> # directive.

#Listen 12.34.56.78:80 Listen 80

(16)

© David Morgan 2003-15

User, Group

User, Group

# If you wish httpd to run as a different user or group, you must run # httpd as root initially and it will switch.

#

# User/Group: The name (or #number) of the user/group to run httpd as. # User apache Group apache from /etc/httpd/conf/httpd.conf from /etc/passwd desktop:x:80:80:desktop:/var/lib/menu/kde:/sbin/nologin postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash apache:x:48:48:Apache:/var/www:/sbin/nologin postfix:x:89:89::/var/spool/postfix:/sbin/nologin squid:x:23:23::/var/spool/squid:/dev/null

ServerAdmin

ServerAdmin

# ServerAdmin: Your address, where problems with the server should be # e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@your-domain.com

#

ServerAdmin webmaster@linnet.edu

(17)

© David Morgan 2003-15

# ServerName gives the name and port that the server uses to identify itself. # This can often be determined automatically, but we recommend you specify # it explicitly to prevent problems during startup.

#

# If this is not set to valid DNS name for your host, server-generated # redirections will not work. See also the UseCanonicalName directive. #

# If your host doesn't have a registered DNS name, enter its IP address here. # You will have to access it by its address anyway, and this will make # redirections work in a sensible way.

# ServerName hostz.linnet.edu:80

ServerName

ServerName

from /etc/httpd/conf/httpd.conf

DocumentRoot

DocumentRoot

# DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations. #

DocumentRoot "/var/www/html"

(18)

© David Morgan 2003-15

UserDir

UserDir

# UserDir: The name of the directory that is appended onto a user's home # directory if a ~user request is received.

#

# The path to the end user account 'public_html' directory must be # accessible to the webserver userid. This usually means that ~userid # must have permissions of 711, ~userid/public_html must have permissions # of 755, and documents contained therein must be world-readable.

# Otherwise, the client will only receive a "403 Forbidden" message.

UserDir public_html

from /etc/httpd/conf/httpd.conf

DirectoryIndex

DirectoryIndex

# DirectoryIndex: sets the file that Apache will serve if a directory # is requested.

#

DirectoryIndex index.html

(19)

© David Morgan 2003-15

Status codes

Status codes

 returned in status line of httpd reply messages

 found in httpd.h

 well-known examples

– 200 – OK

– 404 – not found

– 500 – internal server error

server

server

-

-

info

info

 enable in httpd.conf

(20)

© David Morgan 2003-15

server

server

-

-

status

status

 enable in httpd.conf

 view by browser

Webalizer

Webalizer

 run “webalizer” on server

 deposits analytics in /var/www/html/usage/

(21)

© David Morgan 2003-15

FILE CONTENT

Subliminal message

References

Related documents

Although many different therapeutic techniques (e.g., group counseling, bibliotherapy, or play therapy) have been used to help neurotypical adolescents who are grieving, there is

 Serious injuries/ill health or dangerous occurrences involving staff and children are reported to the Health and Safety Executive using the 2013 RIDDOR form, this will be

Features Windows SharePoint Services 3.0 SharePoint Server 2007 for Search Forms Server 2007 SharePoint Server 2007 Standard CAL SharePoint Server 2007 Enterprise CAL

Distributed Web-Based Systems Essence: The WWW is a huge client-server system with millions of servers; each server hosting thousands of hyperlinked documents: Client machine Browser

for the intensive project workshop which shall carry three times the academic credits (please see (2) below).AM with relevant experience may apply and admission is subject to HKU

In polar coordinates, iris boundaries are horizontal edge points, non-iris boundary that caused by iris textures, eyelashes, eyelids, and lamp-house are not horizontal edge points..

Attach one wire to the Lockon spring clip terminal labeled “1” and connect it to the power terminal labeled “A”6. All Controller connections are illustrated in

Inject a controlled QEMUTimer into qemu-kvm at a known address Eject the emulated ISA bridge.. Force an allocation into the freed RTCState, with second_timer pointing at our