Score:0

Nginx Server Block Not Redirecting Properly

tw flag

I've just recently swapped over to nginx from apache2, and it seems to be handling load times much better. However, I've now lost access to my forum subdomain. Whenever I goto my forum's subdomain, it just redirects me to my site's root directory. I've enabled the site and made the link to the sites-available directory. Here's my current server block:

  server {
    listen 80;
    server_name forum.project-freedom.net;
    root /var/www/forum;

    index index.html index.htm index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.0-fpm.sock;
    }
 }

My main websites directory is /var/www/html/

Upon checking my nginx error log, I've seen I got this error:

2023/04/16 05:26:20 [error] 45598#45598: *65 open() "/var/www/html/service_worker.js" failed (2: No such file or directory), client: 172.70.34.128, server: _, request: "GET /service_worker.js HTTP/2.0", host: "forum.project-freedom.net">
2023/04/16 05:35:07 [error] 45598#45598: *257 open() "/var/www/html/service_worker.js" failed (2: No such file or directory), client: 172.70.135.196, server: _, request: "GET /service_worker.js HTTP/2.0", host: "forum.project-freedom.ne>
2023/04/16 05:35:37 [error] 45598#45598: *258 "/var/www/html/project-freedom.net/index.php" is not found (2: No such file or directory), client: 162.158.78.139, server: _, request: "GET /project-freedom.net/ HTTP/2.0", host: "project-fr>
2023/04/16 05:42:20 [error] 45598#45598: *416 open() "/var/www/html/service_worker.js" failed (2: No such file or directory), client: 172.70.38.15, server: _, request: "GET /service_worker.js HTTP/2.0", host: "forum.project-freedom.net">
2023/04/16 05:42:32 [notice] 46586#46586: signal process started
<dom.net", referrer: "https://forum.project-freedom.net/service_worker.js"
Richard Smith avatar
jp flag
Nginx is not using that `server` block. It's using the one with the `server_name _;` statement (see the error log in your question). Use `nginx -T` (uppercase `T`) to view the entire configuration across all included files and ensure that the `server` block for `forum.project-freedom.net` appears.
Michael Griffith avatar
tw flag
I'm getting this reply when I do `nginx -T`: `nginx: [emerg] the size 52428800 of shared memory zone "SSL" conflicts with already declared size 10485760 in /etc/nginx/sites-enabled/project-freedom.net:23 nginx: configuration file /etc/nginx/nginx.conf test failed`
Richard Smith avatar
jp flag
Nginx will not restart until you fix that fatal error. Without seeing the full output of `nginx -T` it is difficult to say where the error is. Edit your question and add further details.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.