Passa ai contenuti principali

Server Aruba Cloud - CentOS 7 - Server LAMP multi PHP - Apache2 - Gestire domini con e senza SSL scegliendo la versione di PHP


Qualche post fa, affrontammo un discorso abbastanza complesso, ovvero costruire un Server (usando una macchina Server Aruba Cloud) dove potevano scegliere, a secondo del sito che dovevamo progettare/trasferire, quale tipo di PHP far eseguire (nella fattispecie o PHP 5.6 o PHP 7.3), per ottimizzare i costi di produzione aziendali e/o personali.

Essendo di suo abbastanza complesso (uno dei cosiddetti fondamentali) sia nella descrizione che nell'attuazione, ci siamo limitati ad implementare il sistema del multi PHP con base di dati comune, solo su porta 80, ovvero il classico http.

Sempre qualche post fa, abbiamo trattato come attivare ed usare SSL su un server con singolo PHP installato, e come gestire gli <iframe> su SSL


Dove eravamo rimasti?

Il famoso incipit con cui Enzo Tortora tornava in TV dopo l'ingiusta accusa di associazione mafiosa, fa da sponda al nostro articolo.

Il precedente Post:  Server Aruba Cloud - CentOS 7 - Installare un Web Server LAMP multi PHP (PHP 5.6 e PHP 7.3), ci aveva lasciato con un server che era pronto (mancava solo il database, esposto in un posto a parte, poiché è argomento tanto a se stante che di completamento di questo su indicato) ad usare o una versione antica di PHP o una più moderna per sviluppare applicazioni su una singola macchina.

Come detto eravamo rimasti alla sola porta 80, ovvero l'http classico, ma ora, vediamo come applicare quanto espresso in questo post: Server Aruba Cloud - CentOS 7 - Installare Virtual Host SSL su Apache2 (porta 443) e come adattarlo al nostro Server Multi PHP (vedi alla fine per un riepilogo di articoli correlati).


Il SSL.conf nella cartella /etc/httpd/conf.d

Come espresso nel post Server Aruba Cloud - CentOS 7 - Installare Virtual Host SSL su Apache2 (porta 443) quando andiamo ad usare il protocollo SSL, tutti i Virtual Host (VH) del nostro sistema sono definiti nel file ssl.conf che si trova (come dice il testo del paragrafo) nella cartella /etc/httpd/conf.d di CentOS 7.

Come descritto nel post Server Aruba Cloud - CentOS 7 - Installare un Web Server LAMP multi PHP (PHP 5.6 e PHP 7.3) noi possiamo definire nel singolo file conf di dominio il tipo di linguaggio PHP-FPM che ci interessa, usando la seguente sintassi prima del tag <Directory [path della cartella del sito del dominio]>


# Parametri della struttura in php 7.3 (1)

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

AddHandler php73-fcgi .php

Action php73-fcgi /cgi-bin/php73.fcgi


oppure


# Parametri della struttura in php 5.6  (2)

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

AddHandler php56-fcgi .php

Action php56-fcgi /cgi-bin/php56.fcgi


In questo modo quando si riavvia il service httpd, ogni dominio usa il linguaggio PHP definito nel VH.

Ovviamente se non definiamo nulla, Apache2 leggerà e "pubblicherà" qualsiasi file php come un file di testo che ha per estensione .php e non interpreterà il codice!


Server Multi PHP con attivazione di SSL senza definizione di versione di linguaggio 


Questa immagine si riferisce alla "pubblicazione" di un file PHP che abbiamo fatto caricare al Server multi PHP dove abbiamo installato il Mod SSL (come descritto nel post specifico) e a sua volta, nel file ssl.conf, abbiamo inserito sia il dominio www.1000vani.it sia in versione non protetta che protetta (ovvero, rispettivamente, con accesso a porta 80 e 443).

Abbiamo attivato il dominio, ma non laversione del linguaggio che dovrà usare.

Per risolvere il problema sia la parte protetta (SSL su porta 443) che la parte non protetta (su porta 80) devono caricare il FastCGI del linguaggio (il codice (1) e/o (2)) prima di avviare le specifiche della Directory (del resto come descritto nel post sul Server Multi PHP)

Quindi, riportando integralmente i due spezzoni (completi) del dominio www.1000vani.it:443 e www.1000vani.it:80 abbiamo:

########################    (3)
###### Porta 443 - Inzio
###
### Creazione del VirtualHost www.1000vani.it
### con certificato ssl 
####
<VirtualHost www.1000vani.it:443>
# General setup for the virtual host, inherited from global configuration
DocumentRoot "/domini/1000vani.it/sicuro"
ServerName www.1000vani.it:443
# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on
#   SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect.  Disable SSLv2 access by default:
#SSLProtocol all -SSLv2 -SSLv3
#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
#SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA
#   Speed-optimized SSL Cipher configuration:
#   If speed is your main concern (on busy HTTPS servers e.g.),
#   you might want to force clients to specific, performance
#   optimized ciphers. In this case, prepend those ciphers
#   to the SSLCipherSuite list, and enable SSLHonorCipherOrder.
#   Caveat: by giving precedence to RC4-SHA and AES128-SHA
#   (as in the example below), most connections will no longer
#   have perfect forward secrecy - if the server's key is
#   compromised, captures of past or future traffic must be
#   considered compromised, too.
#SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:MEDIUM:!aNULL:!MD5
#SSLHonorCipherOrder on 
#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
### fatto con openssl - test
#SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
### fatto con zerossl
SSLCertificateFile       /etc/ssl/1000vani.it/certificate.crt
#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
### fatto con openssl - test
#SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
### fatto con zerossl
SSLCertificateKeyFile    /etc/ssl/1000vani.it/private.key
#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
### fatto con zerossl
SSLCertificateChainFile  /etc/ssl/1000vani.it/ca_bundle.crt
#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt


#   Client Authentication (Type):
#   Client certificate verification type and depth.  Types are
#   none, optional, require and optional_no_ca.  Depth is a
#   number which specifies how deeply to verify the certificate
#   issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth  10
#   Access Control:
#   With SSLRequire you can do per-directory access control based
#   on arbitrary complex boolean expressions containing server
#   variable checks and other lookup directives.  The syntax is a
#   mixture between C and Perl.  See the mod_ssl documentation
#   for more details.
#<Location />
#SSLRequire (    %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
#            and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
#            and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
#            and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
#            and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20       ) \
#           or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#</Location>
#   SSL Engine Options:
#   Set various options for the SSL engine.
#   o FakeBasicAuth:
#     Translate the client X.509 into a Basic Authorisation.  This means that
#     the standard Auth/DBMAuth methods can be used for access control.  The
#     user name is the `one line' version of the client's X.509 certificate.
#     Note that no password is obtained from the user. Every entry in the user
#     file needs this password: `xxj31ZMTZzkVA'.
#   o ExportCertData:
#     This exports two additional environment variables: SSL_CLIENT_CERT and
#     SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
#     server (always existing) and the client (only existing when client
#     authentication is used). This can be used to import the certificates
#     into CGI scripts.
#   o StdEnvVars:
#     This exports the standard SSL/TLS related `SSL_*' environment variables.
#     Per default this exportation is switched off for performance reasons,
#     because the extraction step is an expensive operation and is usually
#     useless for serving static content. So one usually enables the
#     exportation for CGI and SSI requests only.
#   o StrictRequire:
#     This denies access when "SSLRequireSSL" or "SSLRequire" applied even
#     under a "Satisfy any" situation, i.e. when it applies access is denied
#     and no other module can change it.
#   o OptRenegotiate:
#     This enables optimized SSL connection renegotiation handling when SSL
#     directives are used in per-directory context. 
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
###### directory generale del sistema da togliere
#<Directory "/var/www/cgi-bin">
    #SSLOptions +StdEnvVars
#</Directory>

# Parametri della struttura in php 5.6
 ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
 AddHandler php56-fcgi .php
 Action php56-fcgi /cgi-bin/php56.fcgi


### cartella di destinazione del dominio
    DirectoryIndex index.html index.htm index.php
<Directory "/domini/1000vani.it/sicuro">
allow from all
AllowOverride All
#Options None    
Require all granted
    </Directory>

#   SSL Protocol Adjustments:
#   The safe and default but still SSL/TLS standard compliant shutdown
#   approach is that mod_ssl sends the close notify alert but doesn't wait for
#   the close notify alert from client. When you need a different shutdown
#   approach you can use one of the following variables:
#   o ssl-unclean-shutdown:
#     This forces an unclean shutdown when the connection is closed, i.e. no
#     SSL close notify alert is send or allowed to received.  This violates
#     the SSL/TLS standard but is needed for some brain-dead browsers. Use
#     this when you receive I/O errors because of the standard approach where
#     mod_ssl sends the close notify alert.
#   o ssl-accurate-shutdown:
#     This forces an accurate shutdown when the connection is closed, i.e. a
#     SSL close notify alert is send and mod_ssl waits for the close notify
#     alert of the client. This is 100% SSL/TLS standard compliant, but in
#     practice often causes hanging connections with brain-dead browsers. Use
#     this only for browsers where you know that their SSL implementation
#     works correctly. 
#   Notice: Most problems of broken clients are also related to the HTTP
#   keep-alive facility, so you usually additionally want to disable
#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
#   "force-response-1.0" for this.
BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
#   Per-Server Logging:
#   The home of a custom SSL log file. Use this when you want a
#   compact non-error SSL logfile on a virtual host basis.
CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
###### Porta 443 - Fine
########################
  
########################
###### Porta 80 - Inziio
###
### - www.1000vani.it:80
### - Con accesso con .htaccess di yourl
### - e con error.log
###### 
<VirtualHost www.1000vani.it:80>
    DocumentRoot "/domini/1000vani.it/non-sicuro"
    #ServerName www.1000vani.it:80

# Parametri della struttura in php 7.3
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
AddHandler php73-fcgi .php
Action php73-fcgi /cgi-bin/php73.fcgi

<Directory "/domini/1000vani.it/non-sicuro">
allow from all
AllowOverride All
#Options None    
Require all granted
</Directory>
</VirtualHost>

###
###### Porta 80 - Fine 
########################


Evidenziati in giallo ci sono i parametri da inserire (il file completo sta qui)

Come il lettore critico avrà avuto occasione di osservare, c'è un paradosso che è stato inserito in (3).

Infatti in questa configurazione https è PHP 5.6, mentre http è PHP 7.3 (a differenza della cover-image).

Questo è di fatto un errore (pure grave sulla carta), ma dimostra con quale malleabilità è possibile modellare la macchina Server in questione, cioè il paradosso del PHP differente addirittura sul servizio SSL o meno, ci dice che, se necessario, è possibile creare delle strutture ad hoc per l'uno o per l'altro tipo di accesso

Essendo questo un articolo che comprende spunti espressi in altri articoli, per comodità inserisco l'elenco completo degli articoli cui si fa riferimento (già ampiamente linkati).

Questo è da leggere come ultimo a summa degli altri.




Bibliografia ragionata
    • Introduttivo alla problematiche generali
    • Specifico nella costruzione dei VirtuaHost su porta 80 e 443
    • Il nostro caso specifico, trattando la macchina come estensione del LAMP precedente, completando con il MariaDB Server (quindi un server minimale completo)
    • La summa degli altri articoli


Commenti

Post più popolari

Link al Web

Lista di Comandi Linux Mozilla FireFox / Thunderbird / FileZilla Portable FireFox Download localizzati FireFox Portable - Pagina download localizzati ThunterBird Portable - Pagina dei download localizzati FileZilla Portable Avast Avast Download Avast Registrazione Vecchie versioni Avast Attivazione della copia gratuita per 1 anno Adobe Reader Get Adobe Acrobat e Adobe Reader Cartella tutte le versioni Adobe Reader da scaricare offline Microsoft 365 Accedere ad area riservata Microsoft 365 Scarica Office (365 o versione unica) dal Sito Microsoft Windows 365 VideoLAN VLC Video Player Pagina di Download di VLC Pix Resizer for Windows Pagina dell'autore del programma WinRAR Preleva winrar Java Runtime & Development Kit (Java SDK) Java SE Downloads NetBeans Java Runtime Editio Download Pagine Facebook Rendere Amministratore di una pagina Convertitore Immagine 2 ASCII Art PICASCII Adobe Flash Pl

Mac OS X - Installare ed usare una stampante sul Print Server GetNet 3 Port 2 USB e 1 LPT

Abbiamo visto come installare il Print Server GetNet 3 in 1 sui più diffusi sistemi operativi Windows (vedi articoli correlati in fondo al post). La "scatoletta" ha anche un protocollo di comunicazione Apple Talk, quindi può essere collegata (fare da tramite) anche a stampanti che abbiano la gestione post script integrata (quasi tutte le stampanti salvo quelle del gruppo Ricoh che hanno bisogno di un apposito moduol installato) sul Mac. Print Server GetNet 1 Parallela e 2 USB Il metodo di installazione è molto simile a quello visto su Windows, con la differenza sostanziale che non è necessario scegliere tra moltissimi modelli, ma si gestisce in modo più semplice. Purtroppo sul Mac non è possibile (allo stato attuale) collegare print server di tipo TP-Link, ovvero replicatori di porta USB su Lan, in quanto non esiste un driver adatto. Detto questo, consideriamo la stampante che vogliamo collegare al Mac. Il caso che abbiamo usato nei precedenti post,

BlackBerry - Importare i dati da altri cellulari

English translated post Un amico mi porta un BlackBerry Pearl 8110 e mi chiede di trasferire i dati dal suo cellulare Nokia a questo telefono. Premesso che personalmente non ho mai reputato il BlackBerry un telefono "semplice", l'operazione si è reputata piuttosto complessa. Scartata l'idea di mandare i vcard via bluetooth (come si fa con quasi tutti i Nokia e Samsung), l'unica alternativa è quella di appoggiarsi a Microsoft Outlook !!! Come fare? 1 - Installare il Microsoft Outlook (XP o 2003) nel proprio PC 2 - Installare (nel caso specifico del Nokia) il programma Nokia PC Suite 3 - Sincronizzare solo la Rubrica (ovviamente dipende sempre se il cellulare Nokia è il Vostro o di un Vostro amico) del Nokia con l'Outlook, così che tutti i dati presenti nella Rubrica siano copiati nella sezione Contatti dell'Outlook 4 - Scaricare l'ultima versione del BlackBerry Desktop Manager (se il pacchetto è quello Vodafone, la versione sul CD non è molto efficac