Jump to content

Drift/Web: Difference between revisions

From Programvareverkstedet
Remove package lists, it's better to keep live versions hosted on temmie directly. Also remove temmie-specific stuff, belongs to a different page
Add outdated header
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{| cellspacing="5" cellpadding="0" style="margin: 0em 0em 1em 0em; border: 1px solid #1DA0E7;  background: #B3DDF4; width: 100%"
| '''''Denne siden er trolig utdatert'''''
|}
[[#Maintenance/Web|English]]
[[#Maintenance/Web|English]]


Denne siden inneholder diverse informasjon om webserveren for PVVs brukere.
Denne siden inneholder diverse informasjon om webserveren for PVVs brukere.


Brukernettsidene hostes for tiden på [[Maskiner/temmie]].
Brukernettsidene hostes for tiden på [[Maskiner/Tom]]


= Apache-konfigurasjon =
= Apache-konfigurasjon =


Relevant apache-konfigurasjon finner du i [https://git.pvv.ntnu.no/Drift/pvv-nixos-config pvv-nixos-config] under <code>hosts/temmie/services/userweb/httpd.nix</code>. Det finnes ingen editerbar <code>/etc/apache2</code>-katalog lenger, endringer gjøres i git-repoet og rulles ut med NixOS.
Relevant apache-konfigurasjon finner du i <code>/etc/apache2</code>. Legg spesielt merke til <code>/etc/apache2/mods-enabled/userdir.conf</conf>


userdir-oppsettet ligger i samme fil, og serverer filer fra <code>/home/pvv/&lt;bokstav&gt;/&lt;bruker&gt;/web-docs</code>.
= PHP-konfigurasjon =


= PHP-konfigurasjon =
== Lasting av URLer med fopen() o.l. ==


== Visning av feilmeldinger ==
Fordi lasting av filer fra en URL via fopen(), include() og tilsvarende funksjoner i PHP er en stor sikkerhetsrisiko er dette slått av på PVV fra og med 7. april 2006. Det vil si at du ikke lenger kan gjøre fing som <pre><nowiki>
$fp = fopen("http://www.foo.com/data.txt", "r")


I utgangspunktet er ikke php-feilmeldinger vist. For at feilmeldinger skal vises, lag filen .htaccess med følgende innhold:
eller


<pre><nowiki>
include("http://www.foo.net/include.html").
php_flag display_errors on
php_value error_reporting E_ALL
</nowiki></pre>
</nowiki></pre>


Filen lages i katalogen til scriptet som skal kjøres.
Dersom du er avhengig av å laste websider eller filer fra andre webservere må du heretter bruke funksjoner som fsockopen() e.l. for å hente filer fra andre maskiner, f.eks.:
<pre><nowiki>
<?php


* [[http://php.net/error_reporting|Liste over hva slags verdier error_reporting kan ha]]
function get_url($host, $path, $port = 80) {


== Opplastingsgrense ==
  $fp = @fsockopen($host, $port, $errno, $errstr, 5.0);
  if (!is_resource($fp)) {
    return $errstr;
  }


Maks størrelse på filopplasting i PHP er satt til 40 MB (<code>post_max_size</code> og <code>upload_max_filesize</code>).
  // Send request
  fputs($fp, "GET $path HTTP/1.0\nHost: $host:$port\n\n");


= Maintenance/Web =
  // Skip HTTP-header
  while (!feof($fp)) {
    $line = fgets($fp, 1024);
    if (trim($line) == '') break;
  }


This page contains various information about the web-server for PVVs users.
  // Read body
  $body = '';
  while (!feof($fp)) { $body .= fgets($fp, 1024); }


The user web pages are currently hosted on [[Maskiner/temmie]].
  fclose($fp);


= Apache-configuration =
  return $body;
}


The relevant apache configuration can be found in [https://git.pvv.ntnu.no/Drift/pvv-nixos-config pvv-nixos-config] under <code>hosts/temmie/services/userweb/httpd.nix</code>. There is no longer an editable <code>/etc/apache2</code> directory, changes are made in the git repository and rolled out with NixOS.
print get_url("www.pvv.ntnu.no", "/");
?>
</nowiki></pre>


The userdir setup lives in the same file, and serves files from <code>/home/pvv/&lt;letter&gt;/&lt;user&gt;/web-docs</code>.
== Visning av feilmeldinger ==


= PHP-configuration =
I utgangspunktet er ikke php-feilmeldinger vist. Til at feilmeldinger skal vises, lag filen .htaccess med følgende innhold:
 
== Displaying of error messages ==
 
By default php error messages are not shown. For error messages to be shown, make the file .htaccess with the following content:


<pre><nowiki>
<pre><nowiki>
Line 53: Line 67:
</nowiki></pre>
</nowiki></pre>


The file must be made in the directory of the script that is to be run.
Filen lages i katalogen til scriptet som skal kjøres.


* [[http://php.net/error_reporting|List of what kind of values error_reporting can have]]
* [http://php.net/error_reporting Liste over hva slags verdier error_reporting kan ha]


== Upload limit ==
= Maintenance/Web =


The maximum size for PHP file uploads is 40 MB (<code>post_max_size</code> and <code>upload_max_filesize</code>).
This pabe contains various information on the web-server for PVVs users.


= Available software =
= PHP-configuration =


CGI and PHP scripts run in a sandbox with a fixed set of programs and libraries. The full definition can be found in <code>hosts/temmie/services/userweb/packages.nix</code> in [https://git.pvv.ntnu.no/Drift/pvv-nixos-config pvv-nixos-config]; if you miss something, ask drift to add it there.
== Loading of URLs with fopen() and such ==


== Programming languages ==
Because the loading of files from an URL by fopen(), include(), and similar functions in PHP is a huge security risc it is disabled at PVV from the 7. of April 2006. It means that you no longer can do things such as  <pre><nowiki>
$fp = fopen("http://www.foo.com/data.txt", "r")


* PHP (both as mod_php and <code>php</code> on the command line)
or
* Perl
* Python 3
* Ruby
* Common Lisp (SBCL)
* Bash


== PHP extensions ==
include("http://www.foo.net/include.html").
</nowiki></pre>


bz2, curl, decimal, gd, imagick, mysqli, mysqlnd, pgsql, posix, protobuf, sqlite3, pdo (pdo_mysql, pdo_pgsql, pdo_sqlite), uuid, xml, xsl, zlib and zstd
If you are dependent on loading webpages or files from other web-servers you hereafter have to use functions such as fsockopen() or similar to fetch files from other machines, to get files from other machines, for an instance:
<pre><nowiki>
<?php


== Perl modules ==
function get_url($host, $path, $port = 80) {


CGI, DBI with DBD::mysql, DBD::Pg and DBD::SQLite, Git, ImageMagick, JSON, Template Toolkit, as well as the perl bindings for ikiwiki, ExifTool, irssi and Nix
  $fp = @fsockopen($host, $port, $errno, $errstr, 5.0);
  if (!is_resource($fp)) {
    return $errstr;
  }


== Python modules ==
  // Send request
  fputs($fp, "GET $path HTTP/1.0\nHost: $host:$port\n\n");


cgi, matplotlib, requests
  // Skip HTTP-header
  while (!feof($fp)) {
    $line = fgets($fp, 1024);
    if (trim($line) == '') break;
  }


== Homepage tools ==
  // Read body
  $body = '';
  while (!feof($fp)) { $body .= fgets($fp, 1024); }


* ikiwiki
  fclose($fp);
* ImageMagick (e.g. <code>convert</code> and <code>identify</code>)
* ExifTool and jhead (EXIF data from images)
* gnuplot
* source-highlight (source code highlighting)


== Version control ==
  return $body;
}


git, cvs, rcs
print get_url("www.pvv.ntnu.no", "/");
?>
</nowiki></pre>


== Networking and file transfer ==
== Displaying of error messages ==


curl, wget, xdg-utils
By default php error messages are not shown. For error messages to be shown, make the file .htaccess with the following content:


== E-mail ==
<pre><nowiki>
 
php_flag display_errors on
sendmail (for scripts that send e-mail)
php_value error_reporting E_ALL
 
</nowiki></pre>
== Cryptography ==
 
GnuPG
 
== Compression and archives ==
 
tar, gzip, bzip2, xz, zstd, lz4, zip, unzip
 
== Other tools ==
 
coreutils, findutils, grep, gawk, sed, diffutils, make, file, less, vim, man, util-linux, which, getfacl/setfacl (acl)
 
If you need anything custom, you migth use nix flakes to create a custom environment a cgi script can utilise.


=== Security and versions ===
The file must be made in the catalog of the script that is to be run.


* Preferably place the packages outside <code>web-docs</code>. If they must live under web-docs, name the directory <code>.venv</code> or similar — directories named <code>.venv</code> and <code>__pycache__</code> are already blocked from download in the apache setup, but a venv named just <code>venv</code> is not.
* [http://php.net/error_reporting List of what kind of values error_reporting can have]
* The Python version on temmie follows nixpkgs and may change on upgrades. You can check it with a minimal CGI script printing <code>sys.version</code>.
* Make sure to keep software uppdated.


__NOTOC__
__NOTOC__

Latest revision as of 09:13, 17 November 2026

Denne siden er trolig utdatert

English

Denne siden inneholder diverse informasjon om webserveren for PVVs brukere.

Brukernettsidene hostes for tiden på Maskiner/Tom

Apache-konfigurasjon

Relevant apache-konfigurasjon finner du i /etc/apache2. Legg spesielt merke til /etc/apache2/mods-enabled/userdir.conf</conf>

PHP-konfigurasjon

Lasting av URLer med fopen() o.l.

Fordi lasting av filer fra en URL via fopen(), include() og tilsvarende funksjoner i PHP er en stor sikkerhetsrisiko er dette slått av på PVV fra og med 7. april 2006. Det vil si at du ikke lenger kan gjøre fing som

$fp = fopen("http://www.foo.com/data.txt", "r")

 eller

include("http://www.foo.net/include.html").

Dersom du er avhengig av å laste websider eller filer fra andre webservere må du heretter bruke funksjoner som fsockopen() e.l. for å hente filer fra andre maskiner, f.eks.:

<?php

function get_url($host, $path, $port = 80) {

  $fp = @fsockopen($host, $port, $errno, $errstr, 5.0);
  if (!is_resource($fp)) {
    return $errstr;
  }

  // Send request
  fputs($fp, "GET $path HTTP/1.0\nHost: $host:$port\n\n");

  // Skip HTTP-header
  while (!feof($fp)) {
    $line = fgets($fp, 1024);
    if (trim($line) == '') break;
  }

  // Read body
  $body = '';
  while (!feof($fp)) { $body .= fgets($fp, 1024); }

  fclose($fp);

  return $body;
}

print get_url("www.pvv.ntnu.no", "/");
?>

Visning av feilmeldinger

I utgangspunktet er ikke php-feilmeldinger vist. Til at feilmeldinger skal vises, lag filen .htaccess med følgende innhold:

php_flag display_errors on
php_value error_reporting E_ALL

Filen lages i katalogen til scriptet som skal kjøres.

Maintenance/Web

This pabe contains various information on the web-server for PVVs users.

PHP-configuration

Loading of URLs with fopen() and such

Because the loading of files from an URL by fopen(), include(), and similar functions in PHP is a huge security risc it is disabled at PVV from the 7. of April 2006. It means that you no longer can do things such as

$fp = fopen("http://www.foo.com/data.txt", "r")

 or

include("http://www.foo.net/include.html").

If you are dependent on loading webpages or files from other web-servers you hereafter have to use functions such as fsockopen() or similar to fetch files from other machines, to get files from other machines, for an instance:

<?php

function get_url($host, $path, $port = 80) {

  $fp = @fsockopen($host, $port, $errno, $errstr, 5.0);
  if (!is_resource($fp)) {
    return $errstr;
  }

  // Send request
  fputs($fp, "GET $path HTTP/1.0\nHost: $host:$port\n\n");

  // Skip HTTP-header
  while (!feof($fp)) {
    $line = fgets($fp, 1024);
    if (trim($line) == '') break;
  }

  // Read body
  $body = '';
  while (!feof($fp)) { $body .= fgets($fp, 1024); }

  fclose($fp);

  return $body;
}

print get_url("www.pvv.ntnu.no", "/");
?>

Displaying of error messages

By default php error messages are not shown. For error messages to be shown, make the file .htaccess with the following content:

php_flag display_errors on
php_value error_reporting E_ALL

The file must be made in the catalog of the script that is to be run.