skip to Main Content

I try to make a nginx 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;
    ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';



location / {

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

    # 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 mydomain.com/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:

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

2

Answers


  1. Chosen as BEST ANSWER

    I finally found the shorter solution. I also had problems with migrating urls path of SMF. just use the Repair_settings.php in the root folder, don't forget to remove it.

    location /forum {
        root /site/;
    
    location ~ .php$ {
        fastcgi_pass unix: /var/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
        }
    }
    

  2. I think the location block ‘/’ is redundant here, try remove it:

    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;
        
        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;
        }
    }
    

    I think will work.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search