Too many redirects

Hello. My instances once down got 500 error so I am looking to what was the problem. But now after I updated them, I see the page gets “too many redirects”. At first, it just shows the Nginx welcome page, I once faced this problem, I don’t remember the details to repair it but only know I changed the Redis server configs. But today I got another error tip, it is:

FrozenError: can't modify frozen String: "# Generated with mastodon:setup on 2021-11-25 12:09:01 UTC\n\n"
/home/mastodon/live/lib/tasks/mastodon.rake:356:in `block (2 levels) in <top (required)>'
/home/mastodon/live/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/home/mastodon/.rbenv/versions/2.7.2/bin/bundle:23:in `load'
/home/mastodon/.rbenv/versions/2.7.2/bin/bundle:23:in `<main>'
Tasks: TOP => mastodon:setup
(See full trace by running task with --trace)```
Sees I can not overwrite .env.production config. Can anyone help me?
Also, I am shame of myself to say it, but I still don't know how to resolve the problem that the website just shows Nginx welcome page. So if you will help me with this problem, I will be more appreciate it. 
Thanks.

Regarding the FrozenError thing, that is a known issue with 3.4.3, and will be fixed in an upcoming release. See Initial installation error reported: FrozenError: can’t modify frozen String - #2 by Claire

As for the issue with nginx, we can’t really help you without you telling us how you’ve tried to set Mastodon up and what your config is. If you haven’t followed that already, Installing from source - Mastodon documentation should be a good starting point.

Hello.
Thank you.
Every time I install/reinstall/update by following the official guide that linked to your link. I only change the default Nginx config from “server-name:example.com” to “server-name:cipioshouse.xyz(it is my instance’s domain)”, no other changes applied. If you prefer the more detailed config then I will post it in a few hours.
BTW, when I try to save and quit the edition of Nginx, it shows that
conflicting server name [::]:80 ignored conflicting server name 0.0.0.0:80 ignored conflicting server name [::]:443 ignored conflicting server name 0.0.0.0:443 ignored

No other error tips showed.
May I ask if these tips matter my Nginx problem. Thank you.

You indeed seem to have a configuration issue with nginx, but I can’t tell you more without seeing the actual configuration files.

Hello. My whole Nginx config is following here:

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

upstream backend {
    server 127.0.0.1:3000 fail_timeout=0;
}

upstream streaming {
    server 127.0.0.1:4000 fail_timeout=0;
}

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=CACHE:10m inactive=7d max_size=1g;

server {
  listen 80;
  listen [::]:80;
  server_name cipioshouse.xyz;
  root /home/mastodon/live/public;
  location /.well-known/acme-challenge/ { allow all; }
  location / { return 301 https://$host$request_uri; }
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name cipioshouse.xyz;

  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ciphers HIGH:!MEDIUM:!LOW:!aNULL:!NULL:!SHA;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:10m;

  # Uncomment these lines once you acquire a certificate:
  # ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
  # ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

  keepalive_timeout    70;
  sendfile             on;
  client_max_body_size 80m;

  root /home/mastodon/live/public;

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  add_header Strict-Transport-Security "max-age=31536000";

  location / {
    try_files $uri @proxy;
  }

  location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
    add_header Cache-Control "public, max-age=31536000, immutable";
    add_header Strict-Transport-Security "max-age=31536000";
    try_files $uri @proxy;
location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) {
    add_header Cache-Control "public, max-age=31536000, immutable";
    add_header Strict-Transport-Security "max-age=31536000";
    try_files $uri @proxy;
  }

  location /sw.js {
    add_header Cache-Control "public, max-age=0";
    add_header Strict-Transport-Security "max-age=31536000";
    try_files $uri @proxy;
  }

  location @proxy {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Proxy "";
    proxy_pass_header Server;

    proxy_pass http://backend;
    proxy_buffering on;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;

    proxy_cache CACHE;
    proxy_cache_valid 200 7d;
    proxy_cache_valid 410 24h;
    proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
    add_header X-Cached $upstream_cache_status;
    add_header Strict-Transport-Security "max-age=31536000";

    tcp_nodelay on;
  }

  location /api/v1/streaming {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Proxy "";

    proxy_pass http://streaming;
    proxy_buffering off;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;

    tcp_nodelay on;
  }

  error_page 500 501 502 503 504 /500.html;
}

Thank you take the time to help.

Which distribution do you use? Where is this file installed?

Hello.

I am using Ubutun 18.04 and this file was installed in /etc/nginx/sites-enabled/mastodon under the root directory.

Thank you.

It appears you are using CloudFlare. I don’t know much about how one sets up their service but I think you misconfigured something on that end. CloudFlare should hit your server using HTTPS, not HTTP, and I think it’s hitting HTTP instead, making your nginx server return a 301 Moved Permanently

That is weird. I can sure I never use any services of Cloudflare since I have no account created on its and no bill information created. One only addition service I added is Mailgun service and it has been successful. Do you think maybe I should contact my server provider or domain register to ask if there are anything related to Cloudflare?

Correct my response. Seems my domain register is using Cloudflare’ NS to resolve the IP. I would try to config it to see if everything will go Ok.

I have tried everything I maybe need to do and most of them get good results. However, the Nginx Welcome page still exists rather than my domain home page. I think it is because of the FrozenError thing. Does anyone have better ideas? Thank you all.

The FrozenError thing is unrelated. Your current issue sounds like a nginx misconfiguration. If nginx was properly configured but Mastodon itself would not work, you would get a 500 or 502 error, not the default nginx page. The configuration file you posted earlier seems ok, so I don’t know what could be wrong.

As for the FrozenError, it has been fixed in Mastodon 3.4.4, which has released the other day.

Hello.
Thank you for clarifying. I sure that I am still using Mastodon v3.4.3, how could I update it to v3.4.4?
Thank you.

Releases are available at Releases · mastodon/mastodon · GitHub and the update instructions are described in Upgrading to a new release - Mastodon documentation and individual release notes.

In this case, you need to do git fetch && git checkout v3.4.4 to get the code for 3.4.4, then RAILS_ENV=production bundle exec rails assets:precompile.

What does the following command say?

find /etc/nginx -type f

Hello.
I got these after I typed the command:

/etc/nginx/koi-utf
/etc/nginx/fastcgi_params
/etc/nginx/sites-available/default
/etc/nginx/sites-available/mastodon
/etc/nginx/sites-available/.mastodon.swo
/etc/nginx/uwsgi_params
/etc/nginx/koi-win
/etc/nginx/win-utf
/etc/nginx/mime.types
/etc/nginx/fastcgi.conf
/etc/nginx/snippets/fastcgi-php.conf
/etc/nginx/snippets/snakeoil.conf
/etc/nginx/proxy_params
/etc/nginx/scgi_params```

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.