User Tools

Site Tools


servers:nginx:files

Information

Prerequisites

Notes

  • TODO

Directory

Main

sudo mkdir -p '/var/www/files' && sudo chown -R 'www-data':'www-data' '/var/www/files' && sync

Subdirectories

  • :!: Change x
sudo mkdir -p '/var/www/files/x' && sudo chown -R 'www-data':'www-data' '/var/www/files' && sync

index

  • :!: Using an index.html in a specific directory causes the file listing to not show
sudo -u 'www-data' -e '/var/www/files/index.html'
Test

Link Sharing

  • Change URL# to a download link
  • Change NAME# to a descriptive name
  • :!: <a href=../>../</a> is intentional and is used to go back to the last page
  • TODO: Maybe make those CHANGEME and use sed to change them if I use this frequently
  • TODO: Figure out what the above TODO meant
sudo mkdir -p '/var/www/files/links' && sudo chown -R 'www-data':'www-data' '/var/www/files' && sudo -u 'www-data' -e '/var/www/files/links/index.html'
<a href=../>../</a>
<br>
<a href=https://www.startpage.com>StartPage</a>
<br>
<a href=URL1>NAME1</a>
<br>
<a href=URL2>NAME2</a>

nginx Configuration

Server Block

sudo -e '/etc/nginx/sites-available/files.conf'
server {
    listen '443' 'ssl' 'http2';
    server_name 'files.realmofespionage.xyz';
    root '/var/www/files';
    index 'index.html';

    include '/etc/nginx/snippets/restrictions.conf';
    include '/etc/nginx/snippets/headers.conf';

    add_header Content-Security-Policy "default-src 'self'" always;

    #access_log /var/log/nginx/files-access.log;
    #error_log /var/log/nginx/files-error.log;

}

Enable Server Block

sudo rm -f '/etc/nginx/sites-enabled/files.conf' && sudo ln -s '/etc/nginx/sites-available/files.conf' '/etc/nginx/sites-enabled' && sudo systemctl reload 'nginx'

Transfer Files To Server

  • Change x to file
scp x espionage724@192.168.1.153:~

Allow Public Access To Files

  • Change x to file
cd '/var/www/files' && sudo mv x && sudo chcon -R -t 'httpd_sys_rw_content_t' '/var/www/files' && sudo chown -R 'nginx':'nginx' '/var/www/files' && cd ~ && sync
servers/nginx/files.txt · Last modified: 2018/12/23 01:51 by Sean Rhone