When using the SSL configuration you must create SSL certificates, otherwise your webserver will fail to start. See the Creating SSL Certificates documentation page to learn how to create these certificates before continuing.
First, remove the default NGINX configuration.
rm /etc/nginx/sites-enabled/default
Now you should paste the contents of the file below, replacing <domain>
with your domain name being used in a file called nameless.conf
and place it in /etc/nginx/sites-available/
, or - if on CentOS, /etc/nginx/conf.d/
.
server {
listen 80;
server_name <domain>;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name <domain>;
root /var/www/html;
index index.php index.html;
# allow larger file uploads
client_max_body_size 100m;
# Barebones TLS configuration example, no OCSP stapling, default ciphers, no HSTS.
# Generate a proper config here: https://ssl-config.mozilla.org
# Don't forget to replace these with the actual paths to your certificates!
ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "frame-ancestors 'self'";
add_header X-Frame-Options "SAMEORIGIN";
add_header Referrer-Policy same-origin;
location / {
try_files $uri $uri/ /index.php?route=$uri&$args;
}
location ~ \.(tpl|cache|htaccess)$ {
return 403;
}
location ^~ /node_modules/ {
return 403;
}
location ^~ /scripts/ {
return 403;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock; # May need to be edited
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
The final step is to enable your NGINX configuration and restart it.
# You do not need to symlink this file if you are using CentOS.
sudo ln -s /etc/nginx/sites-available/nameless.conf /etc/nginx/sites-enabled/nameless.conf
# Reload NGINX
nginx -s reload
First, remove the default NGINX configuration.
rm /etc/nginx/sites-enabled/default
Now you should paste the contents of the file below, replacing <domain>
with your domain name being used in a file called nameless.conf
and place it in /etc/nginx/sites-available/
, or - if on CentOS, /etc/nginx/conf.d/
.
server {
listen 80;
server_name <domain>;
root /var/www/html;
index index.php index.html;
# allow larger file uploads
client_max_body_size 100m;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Content-Security-Policy "frame-ancestors 'self'";
add_header X-Frame-Options "SAMEORIGIN";
add_header Referrer-Policy same-origin;
location / {
try_files $uri $uri/ /index.php?route=$uri&$args;
}
location ~ \.(tpl|cache|htaccess)$ {
return 403;
}
location ^~ /node_modules/ {
return 403;
}
location ^~ /scripts/ {
return 403;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock; # May need to be edited
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
The final step is to enable your NGINX configuration and restart it.
# You do not need to symlink this file if you are using CentOS.
sudo ln -s /etc/nginx/sites-available/nameless.conf /etc/nginx/sites-enabled/nameless.conf
# Reload NGINX
nginx -s reload
First, remove the default Apache configuration.
a2dissite 000-default.conf
Now you should paste the contents of the file below, replacing <domain>
with your domain name being used in a file called nameless.conf
and place it in /etc/apache2/sites-available
, or - if on CentOS, /etc/httpd/conf.d/
.
Note: When using Apache, make sure you have the libapache2-mod-php
package installed or else PHP will not display on your webserver.
<VirtualHost *:80>
ServerName <domain>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName <domain>
DocumentRoot "/var/www/html"
AllowEncodedSlashes NoDecode
php_value upload_max_filesize 100M
php_value post_max_size 100M
<Directory "/var/www/html">
Require all granted
AllowOverride all
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/<domain>/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/<domain>/privkey.pem
</VirtualHost>
Once you've created the file above, simply run the commands below. If you are on CentOS you do not need to run the commands below! You only need to run systemctl restart httpd
.
# You do not need to run any of these commands on CentOS
sudo ln -s /etc/apache2/sites-available/nameless.conf /etc/apache2/sites-enabled/nameless.conf
sudo a2enmod rewrite
sudo a2enmod ssl
systemctl restart apache2
First, remove the default Apache configuration.
a2dissite 000-default.conf
Now you should paste the contents of the file below, replacing <domain>
with your domain name being used in a file called nameless.conf
and place it in /etc/apache2/sites-available
, or - if on CentOS, /etc/httpd/conf.d/
.
Note: When using Apache, make sure you have the libapache2-mod-php
package installed or else PHP will not display on your webserver.
<VirtualHost *:80>
ServerName <domain>
DocumentRoot "/var/www/html"
AllowEncodedSlashes NoDecode
php_value upload_max_filesize 100M
php_value post_max_size 100M
<Directory "/var/www/html">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
Once you've created the file above, simply run the commands below. If you are on CentOS you do not need to run the commands below! You only need to run systemctl restart httpd
.
# You do not need to run any of these commands on CentOS
sudo ln -s /etc/apache2/sites-available/nameless.conf /etc/apache2/sites-enabled/nameless.conf
sudo a2enmod rewrite
systemctl restart apache2