Support Newb question

Haboob

Registered
So, I am trying to make the XenForo API work on my NGINX webserver, however I have an issue where whenever I try to access the API domain I get a 404 error.
I access it at https://example.com/forums/api
Basically, what I am asking is how do I setup my NGINX webserver config so that the API will work?
Thanks.
 

kulasglenie

Registered
So, I am trying to make the XenForo API work on my NGINX webserver, however I have an issue where whenever I try to access the API domain I get a 404 error.
I access it at https://example.com/forums/apigrow a garden
Basically, what I am asking is how do I setup my NGINX webserver config so that the API will work?
Thanks.
To get the XenForo API working on your NGINX webserver at https://example.com/forums/api, you need to ensure that your NGINX configuration correctly routes requests to the appropriate XenForo scripts, typically the index.php file within your XenForo installation.
Here's a general setup you can adapt to your server configuration:
Code:
server {
    listen 80;
    server_name example.com;

    root /path/to/your/xenforo/installation;
    index index.php;

    # Redirect HTTP to HTTPS if needed
    # listen 443 ssl;  # Uncomment if using SSL
    # ssl_certificate /path/to/cert.pem;
    # ssl_certificate_key /path/to/key.pem;

    location /forums/ {
        try_files $uri $uri/ /forums/index.php?$query_string;
    }

    # Optional: specific location for /forums/api
    location /forums/api {
        try_files $uri /forums/index.php?$query_string;
    }

    # PHP-FPM configuration
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/phpX.X-fpm.sock; # Update PHP version
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Deny access to hidden files
    location ~ /\.ht {
        deny all;
    }
}
 
Back
Top Bottom