And add init.d script for pveproxy.
use strict;
use warnings;
-use Apache2::Const qw(:http);
use PVE::pvecfg;
use PVE::RESTHandler;
my $loginfo = $reqstate->{log};
- # like apache2 combined log format
+ # like apache2 common log format
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""
my $peerip = $reqstate->{peer_host} || '-';
use PVE::SafeSyslog;
use PVE::Tools;
use PVE::API2;
-use Apache2::Const;
-use mod_perl2;
use JSON;
use LWP::UserAgent;
use HTTP::Request::Common;
my $baseuri = "/api2";
-# http://perl.apache.org/docs/2.0/api/Apache2/SubProcess.html
-
my $debug_enabled;
sub enable_debug {
$debug_enabled = 1;
if (is_error($res->{status})) {
$success = 0;
$new->{message} = $res->{message} || status_message($res->{status});
- $new->{status} = $res->{status} || HTTP_OK;
+ $new->{status} = $res->{status} || 200;
$res->{message} = undef;
- $res->{status} = HTTP_OK;
+ $res->{status} = 200;
}
$new->{success} = $success;
}
return $code;
}
-
if (my $cookie = $response->header("Set-Cookie")) {
$r->err_headers_out()->add("Set-Cookie" => $cookie);
}
debug_msg("proxy end $method $host:$abs_uri ($code)");
- return OK;
+ return HTTP_OK;
}
my $exc_to_res = sub {
return wantarray ? ($rel_uri, $format) : $rel_uri;
}
+1;
+
+__END__
+
my $known_methods = {
GET => 1,
POST => 1,
sub handler {
my($r) = @_;
+ die "we do not use this any longer";
+
debug_msg("perl handler called");
$request_count++;
return OK;
}
-1;
SCRIPTS = \
pve-manager \
pvedaemon \
+ pveproxy \
pvebanner \
pvestatd \
pvenetcommit
--- /dev/null
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: pveproxy
+# Required-Start: $remote_fs $network $syslog pvedaemon
+# Required-Stop: $remote_fs $network $syslog pvedaemon
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: PVE API Proxy Server
+### END INIT INFO
+
+. /lib/lsb/init-functions
+
+PATH=/sbin:/bin:/usr/bin:/usr/sbin
+DAEMON=/usr/bin/pveproxy
+NAME=pveproxy
+DESC="PVE API Proxy Server"
+PIDFILE=/var/run/pveproxy.pid
+
+test -f $DAEMON || exit 0
+
+# avoid warnings about uninstalled locales when pveproxy executes commands
+export LC_ALL="C"
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting $DESC" "$NAME"
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
+ log_end_msg $?
+ ;;
+ stop)
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ start-stop-daemon --stop --quiet --retry TERM/2/TERM/10/KILL/2 --pidfile $PIDFILE
+ log_end_msg $?
+ ;;
+ reload)
+ log_daemon_msg "Reloading $DESC" "$NAME"
+ if ( [ -e $PIDFILE ] && kill -0 `cat $PIDFILE`) then
+ start-stop-daemon --stop --signal HUP --pidfile $PIDFILE
+ else
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
+ fi
+ log_end_msg $?
+ ;;
+ restart|force-reload)
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ start-stop-daemon --stop --quiet --retry TERM/2/TERM/10/KILL/2 --pidfile $PIDFILE
+ sleep 2
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
+ log_end_msg $?
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ echo "Usage: $N {start|stop|restart|force-reload}"
+ exit 1
+ ;;
+esac
+
+exit 0
/etc/init.d/pve-manager
/etc/init.d/pvedaemon
+/etc/init.d/pveproxy
/etc/init.d/pvebanner
/etc/init.d/pvenetcommit
/etc/init.d/pvestatd
/etc/cron.daily/pve
-/etc/apache2/sites-available/pve.conf
-/etc/apache2/sites-available/pve-redirect.conf
/etc/vz/vznet.conf
/etc/vzdump.conf
Section: admin
Priority: optional
Architecture: amd64
-Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libanyevent-perl, libio-compress-perl
+Depends: perl5, libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libanyevent-perl, libio-compress-perl
Conflicts: netcat-openbsd, vzdump
Replaces: vzdump
Provides: vzdump
test -e /proxmox_install_mode || invoke-rc.d pvedaemon restart
test -e /proxmox_install_mode || invoke-rc.d pvestatd restart
- test -e /proxmox_install_mode || invoke-rc.d apache2 restart
+ test -e /proxmox_install_mode || invoke-rc.d pveproxy restart
exit 0;;
test -f /etc/lsb-base-logging.sh || echo "FANCYTTY=0" >/etc/lsb-base-logging.sh
update-rc.d pvedaemon defaults 21 79 >/dev/null
+ update-rc.d pveproxy defaults 21 79 >/dev/null
update-rc.d pvestatd defaults 21 79 >/dev/null
update-rc.d pvebanner start 99 2 3 4 5 . >/dev/null
update-rc.d pvenetcommit start 15 S . >/dev/null
update-rc.d pve-manager defaults 25 75 >/dev/null
test -e /proxmox_install_mode || invoke-rc.d pvedaemon restart
+ test -e /proxmox_install_mode || invoke-rc.d pveproxy restart
test -e /proxmox_install_mode || invoke-rc.d pvestatd restart
- a2enmod perl >/dev/null 2>&1
- a2enmod ssl >/dev/null 2>&1
- a2enmod rewrite >/dev/null 2>&1
- a2enmod proxy >/dev/null 2>&1
-
- a2dissite default >/dev/null 2>&1 || true
- a2ensite pve.conf >/dev/null 2>&1
-
- test -e /proxmox_install_mode || invoke-rc.d apache2 restart
+ #a2ensite pve.conf >/dev/null 2>&1
# There are three sub-cases:
if test "${2+set}" != set; then
if [ "$1" = purge ]; then
update-rc.d pvedaemon remove >/dev/null 2>&1
+ update-rc.d pveproxy remove >/dev/null 2>&1
update-rc.d pvestatd remove >/dev/null 2>&1
update-rc.d pvebanner remove >/dev/null 2>&1
update-rc.d pvenetcommit remove >/dev/null 2>&1
-SUBDIRS = templates images ext4 css manager
+SUBDIRS = images ext4 css manager
all: ${SUBDIRS}
all: pvemanagerlib.js
.PHONY: install
-install: pvemanagerlib.js startup.pl index.pl
- install -d ${WWWBASEDIR}
- install -m 0755 -o www-data -g www-data startup.pl ${WWWBASEDIR}
- install -d ${WWWROOTDIR}
- install -m 0755 -o www-data -g www-data index.pl ${WWWROOTDIR}
+install: pvemanagerlib.js
+ install -d ${WWWBASEDIR}/root
install -d ${WWWEXT4DIR}
install -m 0644 -o www-data -g www-data pvemanagerlib.js ${WWWEXT4DIR}
+++ /dev/null
-#!/usr/bin/perl -w
-
-use strict;
-use mod_perl2 '1.9922';
-use Encode;
-use CGI;
-use PVE::JSONSchema;
-use PVE::AccessControl;
-use PVE::REST;
-
-sub send_output {
- my ($r, $data) = @_;
-
- $r->no_cache (1);
- my $x = length ($data);
- $r->content_type ("text/html;charset=UTF-8");
- $r->headers_out->set ("Content-length", "$x");
- $r->headers_out->set ("Pragma", "no-cache");
-
- $r->print ($data);
-}
-
-# NOTE: Requests to this page are not authenticated
-# so we must be very careful here
-
-my $lang = 'en';
-
-my $r = Apache2::RequestUtil->request();
-my $username;
-my $token = 'null';
-if (my $cookie = $r->headers_in->{Cookie}) {
-
- if (my $newlang = ($cookie =~ /(?:^|\s)PVELangCookie=([^;]*)/)[0]) {
- if ($newlang =~ m/^[a-z]{2,3}(_[A-Z]{2,3})?$/) {
- $lang = $newlang;
- }
- }
-
- my $ticket = PVE::REST::extract_auth_cookie($cookie);
- if (($username = PVE::AccessControl::verify_ticket($ticket, 1))) {
- $token = PVE::AccessControl::assemble_csrf_prevention_token($username);
- }
-}
-
-$username = '' if !$username;
-
-my $cgi = CGI->new($r);
-my %args = $cgi->Vars();
-
-my $workspace = defined($args{console}) ?
- "PVE.ConsoleWorkspace" : "PVE.StdWorkspace";
-
-my $jssrc = <<_EOJS;
-if (!PVE) PVE = {};
-PVE.UserName = '$username';
-PVE.CSRFPreventionToken = '$token';
-_EOJS
-
-my $langfile = "/usr/share/pve-manager/ext4/locale/ext-lang-${lang}.js";
-$jssrc .= PVE::Tools::file_get_contents($langfile) if -f $langfile;
-
-my $i18nsrc;
-$langfile = "/usr/share/pve-manager/root/pve-lang-${lang}.js";
-if (-f $langfile) {
- $i18nsrc = PVE::Tools::file_get_contents($langfile);
-} else {
- $i18nsrc = 'function gettext(buf) { return buf; }';
-}
-
-$jssrc .= <<_EOJS;
-
-// we need this (the java applet ignores the zindex)
-Ext.useShims = true;
-
-Ext.History.fieldid = 'x-history-field';
-
-Ext.onReady(function() { Ext.create('$workspace');});
-
-_EOJS
-
-my $page = <<_EOD;
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
- <title>Proxmox Virtual Environment</title>
-
- <link rel="stylesheet" type="text/css" href="/pve2/ext4/resources/css/ext-all.css" />
- <link rel="stylesheet" type="text/css" href="/pve2/css/ext-pve.css" />
-
- <script type="text/javascript">$i18nsrc</script>
- <script type="text/javascript" src="/pve2/ext4/ext-all-debug.js"></script>
- <script type="text/javascript" src="/pve2/ext4/pvemanagerlib.js"></script>
- <script type="text/javascript">$jssrc</script>
-
- </head>
- <body>
- <!-- Fields required for history management -->
- <form id="history-form" class="x-hidden">
- <input type="hidden" id="x-history-field"/>
- </form>
- </body>
-</html>
-_EOD
-
-send_output ($r, $page);
-exit (0);
+++ /dev/null
-#!/usr/bin/perl -w
-
-use strict;
-
-use PVE::SafeSyslog;
-
-use ModPerl::Util (); #for CORE::GLOBAL::exit
-
-use Apache2::RequestRec ();
-use Apache2::RequestIO ();
-use Apache2::RequestUtil ();
-use Apache2::Access;
-use Apache2::Response;
-use Apache2::Util;
-
-use Apache2::ServerUtil ();
-use Apache2::Connection ();
-use Apache2::Log ();
-
-use APR::Table ();
-
-use ModPerl::Registry ();
-
-use Apache2::Const -compile => ':common';
-use APR::Const -compile => ':common';
-
-initlog ('proxwww', 'daemon');
-
-use PVE::pvecfg;
-use PVE::REST;
-use PVE::Cluster;
-use PVE::INotify;
-use PVE::RPCEnvironment;
-
-sub childinit {
- # syslog ('info', "Starting new child $$");
-
- eval {
- PVE::INotify::inotify_init();
- PVE::RPCEnvironment->init('pub');
- };
- my $err = $@;
- syslog('err', $err) if $err;
-}
-
-sub childexit {
- # BUG: seems this is not called if we do $r->child_terminate()
- # syslog ('info', "Finish child $$");
-}
-
-my $s = Apache2::ServerUtil->server;
-$s->push_handlers(PerlChildInitHandler => \&childinit);
-$s->push_handlers(PerlChildExitHandler => \&childexit);
-
-1;
-
+++ /dev/null
-ve-pve.auto.conf-sample
-ve-pve.auto.conf-sample.tmp
+++ /dev/null
-include ../../defines.mk
-
-all:
-
-.PHONY: install
-install: pve.conf pve-redirect.conf
- install -d ${DESTDIR}/etc/vz/conf
- install -d ${DESTDIR}/etc/apache2/sites-available/
- install -m 0644 pve.conf pve-redirect.conf ${DESTDIR}/etc/apache2/sites-available/
-
-.PHONY: distclean
-distclean: clean
-
-.PHONY: clean
-clean:
- rm -rf *~
+++ /dev/null
-<VirtualHost *:80>
- #RewriteLog "/root/rewrite.log"
- #RewriteLogLevel 10
- RewriteEngine on
- RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
- RewriteRule .* - [F]
- RewriteRule ^/(.*) https://%{HTTP_HOST}:8006/$1 [L,R]
-</VirtualHost>
-
-<VirtualHost *:443>
- SSLEngine on
- SSLProtocol all -SSLv2
- SSLCertificateFile /etc/pve/local/pve-ssl.pem
- SSLCertificateKeyFile /etc/pve/local/pve-ssl.key
-
- RewriteEngine on
- RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
- RewriteRule .* - [F]
- RewriteRule ^/(.*) https://%{HTTP_HOST}:8006/$1 [L,R]
-</VirtualHost>
-
+++ /dev/null
-<IfModule mpm_prefork_module>
- StartServers 2
- MinSpareServers 1
- MaxSpareServers 2
- MaxClients 50
- MaxRequestsPerChild 200
-</IfModule>
-
-ServerName localhost
-ServerSignature Off
-ServerTokens Prod
-ServerAdmin root
-AddDefaultCharset On
-
-# Hint1: Ajax use KeepAlive. We wnat that to get better performance.
-# Hint2: We need to limit the number of request to avoid exhaustive
-# memory usage (we still have small memory leaks).
-# Apache KeepAlive in effect disables MaxRequestsPerChild,
-# (max request are MaxRequestsPerChild*MaxKeepAliveRequests)
-# so we implemented and additional limit in REST.pm
-
-# But KeepAlive spawns too many processes - so we disable that for now
-KeepAlive off
-MaxKeepAliveRequests 200
-
-<IfModule mod_deflate.c>
- AddOutputFilterByType DEFLATE application/json
-</IfModule>
-
-CustomLog ${APACHE_LOG_DIR}/access.log combined
-
-Listen 8006
-<VirtualHost *:8006>
- SSLEngine on
- SSLProtocol all -SSLv2
- SSLCertificateFile /etc/pve/local/pve-ssl.pem
- SSLCertificateKeyFile /etc/pve/local/pve-ssl.key
-
- RewriteEngine on
- RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
- RewriteRule .* - [F]
-
- DocumentRoot /usr/share/pve-manager/root
- <Directory />
- Options FollowSymLinks
- AllowOverride None
- </Directory>
-
- <Directory /usr/share/pve-manager/root>
- Options FollowSymLinks MultiViews
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
- <Directory /usr/share/pve-manager/css>
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
- <Directory /usr/share/pve-manager/ext4>
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
- <Directory /usr/share/pve-manager/images>
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
- <Directory /usr/share/vncterm>
- AllowOverride None
- Order allow,deny
- allow from all
- </Directory>
-
- Alias /pve2/css/ /usr/share/pve-manager/css/
- Alias /pve2/ext4 /usr/share/pve-manager/ext4/
- Alias /pve2/images/ /usr/share/pve-manager/images/
- Alias /vncterm/ /usr/share/vncterm/
-
- # avoid authentication when accessing favicon
- Alias /favicon.ico /usr/share/pve-manager/images/favicon.ico
-
- PerlRequire /usr/share/pve-manager/startup.pl
-
- <Location /index.pl>
- SetHandler perl-script
- PerlHandler ModPerl::Registry
- Options ExecCGI
- </Location>
-
- <Location /api2/>
- SetHandler perl-script
- PerlHandler PVE::REST
- </Location>
-
-</VirtualHost>
-