Web server

From Sinfronteras
Revision as of 10:39, 17 June 2018 by Adelo Vieira (talk | contribs) (Apache User/Group Name and ID)
Jump to: navigation, search

In computing, a server is a computer program or a device that provides functionality for other programs or devices, called "clients". Typical servers are database servers, file servers, mail servers, print servers, web servers, game servers, and application servers.

The computer that a server program runs in is also frequently referred to as a server (Server machine).

A web server is a computer system that processes requests via HTTP, the basic network protocol used to distribute information on the World Wide Web. https://en.wikipedia.org/wiki/Web_server

Apache

The Apache HTTP Server, colloquially called Apache, is the world's most used web server software.

Instalación de Apache

Apache User/Group Name and ID

En esta página se muestran varios métodos para obtener el User and Group of Apache: https://www.cyberciti.biz/faq/unix-osx-linux-find-apache-user/

apachectl -S
ps aux | egrep '([a|A]pache|[h|H]ttpd)'
ps aux | egrep '([a|A]pache|[h|H]ttpd)' | awk '{ print $1}' | uniq | tail -1
ps -ef | egrep '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'

Para desplegar el Apache user-id (UID) and groupd-id: http://www.digimantra.com/linux/find-users-uid-gid-linux-unix/

id -u www-data id -g www-data

El comando id despliega el id de cualquier usuario o grupo (no sólo del Apache user).

Start/Stop/Restart Apache Service

sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart

How do I change the root directory of an apache server

http://stackoverflow.com/questions/5891802/how-do-i-change-the-root-directory-of-an-apache-server

https://www.digitalocean.com/community/tutorials/how-to-move-an-apache-web-root-to-a-new-location-on-ubuntu-16-04


Please note, that this only applies for Ubuntu 14.04 LTS and newer releases.

In my Ubuntu 14.04 LTS, the document root was set to /var/www/html. It was configured in the following file:

/etc/apache2/sites-available/000-default.conf

So just do a

sudo nano /etc/apache2/sites-available/000-default.conf

and change the following line to what you want:

DocumentRoot /var/www/html

Also do a

sudo nano /etc/apache2/apache2.conf

and find this

<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

and change /var/www/html to your preferred directory

and save it.

After you saved your changes, just restart the apache2 webserver and you'll be done :)

Change Apache HTTP default Port

https://www.tecmint.com/change-apache-port-in-linux/

sudo vi /etc/apache2/ports.conf     [On Debian/Ubuntu]
sudo vi /etc/httpd/conf/httpd.conf  [On RHEL/CentOS]

NGINX HTTP Server

Install NGINX on Unbuntu/Debian

sudo apt-get install nginx

Start/Stop/Restart NGINX service

sudo systemctl start   nginx.service
sudo systemctl stop    nginx.service
sudo systemctl restart nginx.service

Change NGINX HTTP default Port

https://websiteforstudents.com/change-nginx-http-server-port-on-ubuntu-16-04-17-10-18-04/

sudo vi /etc/nginx/sites-available/default
 server {
        listen 8082 default_server;
        listen [::]:8082 default_server;
...

Usar dos Web server (por ejemplo Apache y NGINX) en la misma computadora

Para poder ingresar a distintos Web servers instalados en la misma computadora, lo único que hay que hacer es configurar puertos distintos para cada servidor. Ver: Web server#Change Apache HTTP default Port

Web server#Change NGINX HTTP default Port

Podría también ser necesario, configurar los Firewalls para poder acceder a otros puertos.

Hide Pages, Files, and Directories from Search Engines as Google - The Robots.txt file

http://etikamarketing.com/inbound-marketing/hide-your-pdf-content-from-search-engines/

En MediaWiki - Robots.txt

https://www.mediawiki.org/wiki/Manual:Robots.txt/fr

Block an IP from your site using htaccess

Block a country from your site using htaccess

http://www.inmotionhosting.com/support/website/htaccess/block-country-ips

De esta forma lo logré hacer:

Este método plantea obtener la lista de IP's a bloquear from here: https://www.ip2location.com/free/visitor-blocker y colocarla en el archivo .htaccess. Éste archivo se coloca en cualquier directorio y afectará todos los subdirectorios. En mi caso lo he colocado en el directorio principal de MediaWiki (/var/www/sinfronteras_ws/perso) para que afecte todas las páginas del MediaWiki


Sin embargo,

Aquí se muestran varias formas de hacerlo: https://www.sitepoint.com/how-to-block-entire-countries-from-accessing-website/

Parece que el método más apropiado es a través es este:

Apache Modules

You don’t have to fill your .htaccess file with thousands of lines of IPs. Instead, you can install a C library and an Apache module to do the heavy lifting for you.

MaxMind provides a popular free database that is often used for IP lookups. Their GeoLite2 is a free database that is updated monthly. Their paid product is more accurate and updated more frequently if you require that.

By using this database and installing one of their various APIs, you can handle traffic as you see fit.

For our purposes, you would need to install the C library API as well as the Apache module. Once those are working and enabled, place the database file somewhere, and then you can set up your country blocks with code as simple as this in the .htaccess or Apache config file...


Explicación de los archivos .htaccess, donde colocarlo y cómo se activa en Apache:

http://webmasters.stackexchange.com/questions/61009/how-to-enable-use-of-htaccess-in-apache-on-ubuntu

http://www.commentcamarche.net/contents/7-apache-les-fichiers-htaccess

https://www.digitalocean.com/community/tutorials/how-to-use-the-htaccess-file