Wondering if this will always be free?  See why free is better.

Main Menu

NGINX CONF for SMF 2.0.19 help

Started by nginxishard, December 14, 2023, 06:25:30 PM

Previous topic - Next topic


Hello, I try to make a conf file , I already an app and phpmyadmin in my conf file :

server {
    listen 80;
    server_name hidden;
    return 301[s]hiddenblabla$request_uri;

server {
    listen *:443 ssl;
    server_name hidden hiddendomain;

    ssl on;
    # Use certificate and key provided by Let's Encrypt:
    ssl_certificate /etc/letsencrypt/live/hidden/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/hidden/privkey.pem;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

location / {

    #resolve using Google's DNS server to force DNS resolution and prevent caching of IPs

    # Proxy_pass configuration
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $hidden;
    proxy_set_header X-NginX-Proxy true;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_max_temp_file_size 0;
    proxy_pass hidden;
    proxy_redirect off;
    proxy_read_timeout 240s;
proxy_hide_header 'Cache-Control';
add_header Cache-Control no-cache;
expires 1d;


        location /phpmyadmin {
        root /usr/share/;
        index index.php index.html index.htm;
        location ~ ^/phpmyadmin/(.+\.php)$ {
            try_files $uri =404;
            root /usr/share/;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include /etc/nginx/fastcgi_params;

        location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            root /usr/share/;

    location /phpMyAdmin {
        rewrite ^/* /phpmyadmin last;

I tried to add this in location / {} after /phpmyadmin{} route because I wish that when I go to hiddendomain.tld/forum I come across the forum (folder in server: site/forum-blockchain)

location /forum {
        root /site/forum-blockchain/;
        index index.php index.html;

        access_log /var/log/nginx/forum.access.log;
        error_log /var/log/nginx/forum.error.log;

        location / {
            try_files $uri $uri/ /index.php?$args;
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;

but in journalctl -xe, I have this error while I do service nginx restart:

Dec 15 00:16:45 nginx[31698]: nginx: [emerg] location "/" is outside location "/forum" in /etc/nginx/sites-enabled/mydomain:78

2hours on this problem, I don't find any solutions...


Ofcourse you can't nest location other way, /forum location block can't be used to nest / (root).

Instead of posting config, could you share what exactly you are looking for ?

Edit: Just noticed, I have posted on  old thread.