Common Gateway Interface (CGI current version 1.1)

Slides:



Advertisements
Similar presentations
CGI & HTML forms CGI Common Gateway Interface  A web server is only a pipe between user-agents  and content – it does not generate content.
Advertisements

1/16 Steven Leung Introduction to HTML/CGI/JavaScript Intro to HTML/CGI/JavaScript How the Web Works HTML: Basic Concept CGI: Basic Concept JavaScript:
Java Script Session1 INTRODUCTION.
Adding Dynamic Content to your Web Site
Utilizing the GDB debugger to analyze programs Background and application.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
Servlets and a little bit of Web Services Russell Beale.
Apache Tomcat Server – installation & use Server-side language-- use Java Server Pages Contrast Client-side languages HTML Forms Servers & Server-side.
Dynamic content 1WUCM1. 2 Basic architecture of the web.
4/8/99 C. Edward Chow Page 1 Internet Services Manager Click Start | Programs | Administrative Tools | Internet Services Manager.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Chapter 6: Hostile Code Guide to Computer Network Security.
 What I hate about you things people often do that hurt their Web site’s chances with search engines.
Linux Operations and Administration
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Apache Server The Apache Server Apache is a WWW server that implements the HTTP protocol. Apache runs as a daemon. This means that it is a resident.
1 HTML and CGI Scripting CSC8304 – Computing Environments for Bioinformatics - Lecture 10.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Internet / Intranet Fall 2000 Class 7. Brandeis University Internet/Intranet Spring Class 7 Agenda Project / Homework Discussion Forms Validating.
Internet / Intranet CIS-536 Class 7. 2 HTML Forms A Method to Allow Users to Pass Information to a CGI Script Forms Allow Information to Be Entered Via:
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Python CGI programming
1 In the good old days... Years ago… the WWW was made up of (mostly) static documents. –Each URL corresponded to a single file stored on some hard disk.
1 Apache. 2 Module - Apache ♦ Overview This module focuses on configuring and customizing Apache web server. Apache is a commonly used Hypertext Transfer.
Introduction to Applets CS 3505 Client Side Scripting with applets.
10/13/2015 ©2006 Scott Miller, University of Victoria 1 Content Serving Static vs. Dynamic Content Web Servers Server Flow Control Rev. 2.0.
Website Development with PHP and MySQL Saving Data.
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
Chapter 6 Server-side Programming: Java Servlets
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
The HTTP is a standard that all Web browsers and Web servers must speak in order for the Web portion of the Internet to work.
Form Data Encoding GET – URL encoded POST – URL encoded
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
Implementing and Using the SIRWEB Interface Setup of the CGI script and web procfile Connecting to your database using HTML Retrieving data using the CGI.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Form Processing Week Four. Form Processing Concepts The principal tool used to process Web forms stored on UNIX servers is a CGI (Common Gateway Interface)
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
More than one site? Use multiple configuration files Use multiple configuration files  httpd –d {path}  Assumes “conf/httpd.conf” Logging transactions.
Server Side Scripting Perl, Python, Java Servlets  write complete programs in (Perl, Python, Java) to process HTTP requests and generate a complete HTTP.
Servers- Apache Tomcat Server Server-side scripts- Java Server Pages.
Introduction to CGI PROG. CGI stands for Common Gateway Interface. CGI is a standard programming interface to Web servers that gives us a way to make.
9/21/04 James Gallagher Server-Side: The Basics This part of the workshop contains an overview of the two servers which OPeNDAP has developed. One uses.
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
9/21/04 James Gallagher Server Installation and Testing: Hands-on ● Install the CGI server with the HDF and FreeForm handlers ● Link data so the server.
The Common Gateway Interface (CGI) Pat Morin COMP2405.
Internet/Web Databases
Distributed Control and Measurement via the Internet
CS 330 Class 7 Comments on Exam Programming plan for today:
Web Protocols and Practice
Apache Web Server v. 2.2 Reference Manual
WWW and HTTP King Fahd University of Petroleum & Minerals
HTTP – An overview.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
Section 17.1 Section 17.2 Add an audio file using HTML
Introduction to Programming the WWW I
Getting web pages First we need to get the webpage by issuing a HTTP request. The best option for this is the requests library that comes with Anaconda:
PHP / MySQL Introduction
MapServer In its most basic form, MapServer is a CGI program that sits inactive on your Web server. When a request is sent to MapServer, it uses.
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 27 WWW and HTTP.
The HTTP Protocol COSC 2206 Internet Tools The HTTP Protocol

Web Application Development Using PHP
Presentation transcript:

Common Gateway Interface (CGI current version 1.1) a standard for external applications to interface with information servers such as HTTP servers http://hoohoo.ncsa.uiuc.edu/docs/cgi/overview.html These external applications typically help to relay info between httpd and other software systems,e.g., DB. This is how CGI gets its gateway name. They are called CGI programs and can be written in any language that follows the CGI spec. PERL, PERL, Unix shell, C/C+, Fortran, TCL, Visual Basic It is executed dynamically, provides dynamic content. 12/31/2018 C. Edward Chow

CGI Security Concerns CGI program runs with ID of the httpd (webuser in our case, nobody in many other web servers) It can retrieve and overwrite files in directories which it has access permission! “Security by Obscurity” Kept at different directory than that for web pages so bad guys can’t read, edit, analyze them for security holes. Example on why apache by default does not allow to follow soft link (ln -s). Bad guy set up ln -s to a script. Then use web browser, through httpd (new permission as webuser) to retrieve the text of the script. 12/31/2018 C. Edward Chow

Apache CGI Configuration Allow read and execute access of the CGI programs, and possible write access to the data directories used by them. ScriptAlias URLpath directory e.g., ScriptAlias /cgi-bin /mpc/home/<login>/sites/cgi-bin Incoming url with /cgi-bin/echoorder.pl cause /mpc/home/<login>/sites/cgi-bin/echoorder.pl to run. 12/31/2018 C. Edward Chow

Apache CGI Exercise 1 cd /mpc/home/<login>/site.cgi/conf Run sub.pl <your port#>. It will modify the go script and conf/httpd.conf Start web server with go On browser, retrieve http://bilbo:<port#>/form_summer.html Fill the form and submit the query. Observe the environment variables returned. 12/31/2018 C. Edward Chow

Apache CGI Exercise 2 The myecho is the object code for Freebsd. Recompile myecho with “make”. cp form_summer.html form_summer2.html Edit the form_summer2.html by replacing /cgi-bin/mycgi with /cgi-bin/myecho in <FORM> tag rename it as form_summer2.html On browser, retrieve http://bilbo:<port#>/form_summer2.html Observe the return web page. 12/31/2018 C. Edward Chow

CGI.pm: A Perl5 CGI Library Echoorder.pl and process.pl are written with the recent version 2.36 of CGI.pm by Lincoln Stein http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html It provides functions for parsing the querying string creating web pages/fill-out forms saving/retrieving the querying string to files HTTP session variables cookie, frame, javascript, and NPH support Debug the perl script by ./<script>.pl enter the query string, e.g., order1=3&order2=4 12/31/2018 C. Edward Chow

Passing Variables to CGI Program SetEnv variable value SetEnv VHOST customers, set env variable value. PassEnv <host env variable> pass host environment variables to CGI program Find out the browser and version number BrowserMatch browserRE env[=val1] env2[=val2] browserRE regular expression match the value in User-Agent header, when matched env var. are set. e.g., BrowserMatch ^Mozilla/[23] tables=3 java frame 12/31/2018 C. Edward Chow

Apache Built-in Handlers Perform certain actions when a file with particular MIME or handler type is called. server-status: Get server’s current status server-info: Get server’s configuration server-parse: Parses server-side includes AddHandler handler-name extension map filename extension to handler-name and wake up an existing handler. e.g., AddHandler cgi-script cgi treat files with .cgi extension as executable CGI script 12/31/2018 C. Edward Chow

SetHandler: Site.status Include “SetHandler <handler-name>“ in block directives, such as <directory> <location> <files> Apply the transformation specified by handler-name to all files in the block. ExtendedStatus On <Location /status> <Limit GET> order deny, allow allow from 128.198 deny from all </Limit> SetHandler server-status </Location> Require mod_access. Method in <limit> must be upper case, e.g., GET instead of get in Apache 1.2.5 <limit get> is ok but not in Apache 1.3.3. allow from 128.198.0.0 is wrong resulting in forbidden access. Append the above in httpd.conf, try http://bilbo:<portno>/status?refresh=5 12/31/2018 C. Edward Chow

Perform Filtering on Certain File Type Site.filter demonstrates the compress of .html using gzip and save it as .zhtml file. How much storage we save in a web site by using this? Overheadcompression, modification of web pages! decompression on retrieval Actually there is an error on index.zhtml The httpd.conf include AddHandler peter-gzipped-html ghtml Action peter-gzipped-html /cgi-bin/unziphtml Action <type> <cgi-script> pass file with type=<type> through <cgi-script> 12/31/2018 C. Edward Chow

Site.Filter unziphtml: #!/bin/sh echo "content-type: text/html" echo gzip -S .zhtml -d -c $PATH_TRANSLATED gzip option: -c write output to stdout. -d decompress -S .zhtml use suffix .zhtml instead of .gz Note that the .ghtml files got garbled. mime.types file format does not allow .html.gz 12/31/2018 C. Edward Chow

Compressing/Modifying Web Pages The web pages provided in site.filter from CD-ROM is not correct. Please regenerate them with the following instruction. Note that before you compressed, you need modify the links to the compressed .zhtml files. mv htdocs to htdoc.orig mkdir htdocs; cd htdocs cp ../../site.virtual/htdocs/customers/* . Replace the <li><A href="catalog_summer.html">Summer catalog </A> <li><A href="catalog_autumn.html">Autumn catalog </A> WITH <li><A href="catalog_summer.zhtml">Summer catalog </A> <li><A href="catalog_autumn.zhtml">Autumn catalog </A> Gzip *.html Rename *.html.gz with *.zhtml 12/31/2018 C. Edward Chow

Homework#4 Exercise 1: Setup site.cgi Exercise 2: Setup site.status Exercise 3: Setup site.filter. 12/31/2018 C. Edward Chow