Configurar Nginx para que sirva la página web y el app MyFitnessFactory hacía el internet
- Nos ubicamos en la siguiente ruta /etc/nginx/sites-available/ del droplet con el siguiente comando
cd /etc/nginx/sites-available
- Editamos el archivo default
nano default
- El archivo default debe contener lo siguiente
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server{
listen 80;
server_name fitnessfactory.com.ec www.fitnessfactory.com.ec;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name fitnessfactory.com.ec www.fitnessfactory.com.ec;
ssl_certificate /etc/letsencrypt/live/fitnessfactory.com.ec/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/fitnessfactory.com.ec/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
server_name _;
location /static/ {
alias /opt/entornoVirtualFitnessFactory/fitnessFactory/static/static-only/;
}
location /media/ {
alias /opt/entornoVirtualFitnessFactory/fitnessFactory/media/;
}
location / {
#include proxy_params;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8000;
#try_files $uri $uri/ =404;
}
location /robots.txt {
alias /opt/entornoVirtualFitnessFactory/fitnessFactory/static/static/robots/robots.txt;
}
}
- Ejecutamos los siguientes comandos para que NGINX tome la configuración realizada
sudo nginx -t
sudo service nginx reload
sudo service nginx restart