Foros del Web » Administración de Sistemas » Software para Servers »

Asegurar phpmyadmin

Estas en el tema de Asegurar phpmyadmin en el foro de Software para Servers en Foros del Web. Al tener phpmyadmin abierto a todo el mundo en plan http://IP/phpmyadmin me gustaría saber como asegurarlo para que sea accesible solo htpps://IP/phpmyadmin También sería interesante ...
  #1 (permalink)  
Antiguo 02/10/2011, 13:51
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Asegurar phpmyadmin

Al tener phpmyadmin abierto a todo el mundo en plan http://IP/phpmyadmin me gustaría saber como asegurarlo para que sea accesible solo htpps://IP/phpmyadmin
También sería interesante saber si se puede bloquear si un usuario intentan acceder más de 3 veces sin éxito.
  #2 (permalink)  
Antiguo 04/10/2011, 15:31
Avatar de XProsite  
Fecha de Ingreso: junio-2009
Ubicación: Houston, TX
Mensajes: 91
Antigüedad: 14 años, 10 meses
Puntos: 5
Respuesta: Asegurar phpmyadmin

Para la conexión segura deberías de instalarle un certificado ssl, aunque no autentificado si lo vas a utilizar para tu ip.
  #3 (permalink)  
Antiguo 05/10/2011, 02:20
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

Existen varias formas

Usando .htacces

Código:
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/directorio(.*)$ https://%{HTTP_HOST}/directorio$1 [L,R]

Modificando config.inc.php de PhpMyadmin:
Código:
// Coloca esto al final del archivo.
$cfg['ForceSSL'] = true;
Personalmente prefiero esta ultima, pero en caso de que no tengas acceso a config.inc.php, tienes la primera opción.
  #4 (permalink)  
Antiguo 05/10/2011, 02:49
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

He hecho eso cube media, pero me da el siguiente error:


Ha ocurrido un error durante una conexión a 78.x.x.x

SSL ha recibido un registro que excedía la longitud máxima permitida.

(Código de error: ssl_error_rx_record_too_long)
  #5 (permalink)  
Antiguo 05/10/2011, 02:51
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

cual de 2 opciones utilizaste?
  #6 (permalink)  
Antiguo 05/10/2011, 02:59
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

La segunda
  #7 (permalink)  
Antiguo 05/10/2011, 03:02
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

Cita:
Iniciado por mitrofan Ver Mensaje
La segunda
Asegurate que ssl este funcionando correctamente antes de hacer el cambio y que el certificado ssl este vigente.

que sistema operativo y panel de control tiene tu servidor?
  #8 (permalink)  
Antiguo 05/10/2011, 03:07
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

No tiene panel, es un vps. Lo hago todo a través de la shell. Es un Debian 6.
  #9 (permalink)  
Antiguo 05/10/2011, 03:22
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

seguro que puso
Código:
$cfg['ForceSSL']  = true;
antes de cerrar el tag php ?> en config.inc.php

anteriormente, funcionaba bien el https??

puede mandarme el url de la pagina? por mensaje si quiere mantener la privacidad.
  #10 (permalink)  
Antiguo 05/10/2011, 03:33
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

Nunca he usado https. Solo lo quiero implementar para phpmyadmin, la web me da igual.
  #11 (permalink)  
Antiguo 05/10/2011, 03:35
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

por eso pregunte anteriormente.
Tienes SSL instalado? Mod_SSL
funciona https para otras paginas/dominios?

asegurate de que ssl este instalado y funcionando antes de forzar phpmyadmin a usar SSL

que Sistema operativo tiene tu vps?
que version de phpmyadmin, apache y php usas? es bueno para tener referencias y poder entendernos mejor.
  #12 (permalink)  
Antiguo 05/10/2011, 03:45
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

Si, entiendo que el modulo se arranca así:
#a2enmod ssl
Module ssl already enabled
#uname -r
2.6.32-5-amd64

Te doy mas datos que he sacado del phpinfo:

PHP Version 5.3.3-7+squeeze3

Apache Version Apache/2.2.16 (Debian)
Apache API Version 20051115
Server Administrator [no address given]
User/Group www-data(33)/33
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 300 - Keep-Alive: 15
Virtual Server Yes
Server Root /etc/apache2
Loaded Modules core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_ssl mod_status

MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 5.1.49
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /var/run/mysqld/mysqld.sock
MYSQL_INCLUDE -I/usr/include/mysql
MYSQL_LIBS -L/usr/lib -lmysqlclient_r

openssl
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8o 01 Jun 2010
OpenSSL Header Version OpenSSL 0.9.8o 01 Jun 2010
  #13 (permalink)  
Antiguo 05/10/2011, 03:52
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

en tu httpd.conf tienes configurado un virtual host para el SSL ?
segun veo, tienes ubuntu/debian apache2.conf seria el file.

si gustas, pon el contenido de tu apache2.conf aca.
  #14 (permalink)  
Antiguo 05/10/2011, 04:00
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

No, pero los virtual host están configurados en:

/etc/apache2/sites-availabe/default

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>

<VirtualHost *:80>
ServerName www.dominio.es
ServerAlias dominio.es *.dominio.es
DirectoryIndex index.php
DocumentRoot /var/www/dominio/
ErrorLog /var/www/dominio/logs/error.log
CustomLog /var/www/dominio/logs/access.log combined

<Directory "/var/www/anuncios/logs/">
Deny from All
</Directory>

</VirtualHost>
  #15 (permalink)  
Antiguo 05/10/2011, 04:01
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

También hay otra que se llama default-ssl

/etc/apache2/sites-availabe/default-ssl

Esta ni la he tocado:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on

# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.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/apache2/ssl.crt/server-ca.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)
# Note: Inside SSLCACertificatePath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCACertificatePath /etc/ssl/certs/
#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

# Certificate Revocation Lists (CRL):
# Set the CA revocation path where to find CA CRLs for client
# authentication or alternatively one huge file containing all
# of them (file must be PEM encoded)
# Note: Inside SSLCARevocationPath you need hash symlinks
# to point to the certificate files. Use the provided
# Makefile to update the hash symlinks after changes.
#SSLCARevocationPath /etc/apache2/ssl.crl/
#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

# 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
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</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-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>
</IfModule>

¿Habrá que configuralo ahí?
  #16 (permalink)  
Antiguo 05/10/2011, 04:04
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

Agrega debajo de
<VirtualHost *:80>
ServerName www.dominio.es
.....
....
</VirtualHost>

esto

Código:
<VirtualHost *:443>
ServerName www.dominio.es
ServerAlias dominio.es *.dominio.es
DirectoryIndex index.php
DocumentRoot /var/www/dominio/
ErrorLog /var/www/dominio/logs/error.log
CustomLog /var/www/dominio/logs/access.log combined

SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem


<Directory "/var/www/anuncios/logs/">
Deny from All
</Directory>
</VirtualHost>
y por supuesto, reiniciar apache

Código:
apache2ctl restart
luego prueba que tu
https://dominio.es funcione,
luego configura la opcion para forzar ssl en phpmyadmin y reinicia apache nuevamente.
  #17 (permalink)  
Antiguo 05/10/2011, 04:38
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

Me sigue dando el mismo error.
El VirtualHost no debería configurarlo en /etc/apache2/conf.d/phpmyadmin.conf?
  #18 (permalink)  
Antiguo 05/10/2011, 04:45
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

Cita:
Iniciado por mitrofan Ver Mensaje
Me sigue dando el mismo error.
El VirtualHost no debería configurarlo en /etc/apache2/conf.d/phpmyadmin.conf?
no importa desde donde configures el virtual host, igual apache carga el archivo de configuracion..


Tienes que poner a funcionar https://dominio.es
una vez tengas configurado ssl, entonces forzas ssl para phpmyadmin.

te recomiendo leas esta guia(en ingles) para autogenerar un certificado SSL (aparentemente no lo tienes)

http://library.linode.com/web-servers/apache/ssl-guides/ubuntu-10.10-maverick

una vez generes el certificado, vas a tener que regresar a modificar el virtual host y cambiar las lineas del SSL especificando el nuevo certificado,(tal y como dice en el tutorial)
  #19 (permalink)  
Antiguo 05/10/2011, 04:53
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

Vale, gracias. Voy a ver lo del certificado. Debe ser eso, porque me da los siguientes errores en los logs:


[Wed Oct 05 12:25:50 2011] [error] [client 95.21.88.164] Invalid method in request \x16\x03\x01
[Wed Oct 05 12:32:46 2011] [notice] caught SIGTERM, shutting down
[Wed Oct 05 12:32:47 2011] [notice] Apache/2.2.16 (Debian) PHP/5.3.3-7+squeeze3 with Suhosin-Patch mod_ssl/2.2.16 OpenSSL/0.9.8o configured -- resuming normal operations
[Wed Oct 05 12:40:36 2011] [error] Init: Private key not found
[Wed Oct 05 12:40:36 2011] [error] SSL Library Error: 218710120 error:0D094068:asn1 encoding routines:d2i_ASN1_SET:bad tag
  #20 (permalink)  
Antiguo 05/10/2011, 04:56
Avatar de cubemedia  
Fecha de Ingreso: octubre-2008
Mensajes: 15
Antigüedad: 15 años, 6 meses
Puntos: 2
Respuesta: Asegurar phpmyadmin

Listo.

ahi esta, necesitas generar el certificado. una vez lo hagas, todo funcionara.

ahi te mande un msg privado..


Suerte.
  #21 (permalink)  
Antiguo 05/10/2011, 09:58
 
Fecha de Ingreso: mayo-2010
Mensajes: 128
Antigüedad: 13 años, 11 meses
Puntos: 13
Respuesta: Asegurar phpmyadmin

Ya está. volví generar el cretificado openssl req -new -x509 -days 999 -nodes -out anuncios.pem -keyout anuncios.pem.

Gracias

Etiquetas: ip, php, phpmyadmin
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 01:33.