Skip to content
whitewillem edited this page Dec 28, 2018 · 1 revision

Add the rewrite rules from nginx.example.conf to your server block

rewrite ^/raw_data$ /raw_data.php?$1 last;
rewrite ^/gym_data$ /gym_data.php?$1 last;
rewrite ^/motd_data$ /motd_data.php?$1 last;
rewrite ^/submit /submit.php?$1 last;
rewrite ^/search /search.php?$1 last;
rewrite ^/weather_data$ /weather_data.php?$1 last;
rewrite ^/serviceWorker.min.js$ /static/dist/js/serviceWorker.min.js last;
rewrite ^/user$ /user.php?$1 last;
rewrite ^/discord-login$ /discord-login.php?$1 last;

Example Config

  1. Replace DOMAINNAME with your domain (ex. github.com)
  2. Replace /PATH/TO/PMSF to the location where your PMSF is installed (ex. /var/www/pmsf) 2 times
  3. Restart Nginx
  • If you are using Ubuntu change fastcgi_pass unix:/var/run/php-main.socket; to one of these depending where your php_fpm is installed:
    • fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
    • fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
server {
    listen 80;
    server_name DOMAINNAME;

    # Some Basic lockdown of folders and files
    # Lock folders
    location ~ /(\.|cron|lib|LICENSE)
    {
        return 444;
    }
    # Lock Extensions
    location ~* \.(conf|md|sql)
    {
        return 444;
    }

    rewrite ^/raw_data$ /raw_data.php?$1 last;
    rewrite ^/gym_data$ /gym_data.php?$1 last;
    rewrite ^/motd_data$ /motd_data.php?$1 last;
    rewrite ^/submit /submit.php?$1 last;
    rewrite ^/search /search.php?$1 last;
    rewrite ^/weather_data$ /weather_data.php?$1 last;
    rewrite ^/serviceWorker.min.js$ /static/dist/js/serviceWorker.min.js last;
    rewrite ^/user$ /user.php?$1 last;
    rewrite ^/discord-login$ /discord-login.php?$1 last;

    #charset koi8-r;

    error_log /var/log/nginx/error.log warn;

    #access_log  logs/host.access.log  main;

    location / {
    include /etc/nginx/mime.types;
        root /PATH/TO/PMSF;
        index index.php index.html index.htm;
    }

    error_page 404 /404.html;
    location = /404.html {
        root /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #


    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root /PATH/TO/PMSF;
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-main.socket;
        fastcgi_index index.php;
        fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;
        fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny all;
    }
}

Clone this wiki locally