Need help to fix ERR 500


#81

@MikeiLL
I test de ofn_deployment with canada-updates branch.
The code is deplyed ans is running.
But I can’t send emails.
When I try to send test email from configuration page, I get this error : Testmail error: Missing host to link to! Please provide the :host
parameter, set default_url_options[:host], or set :only_path to true

I try to create an enterprise, and I don’t receive confirmation email.

I don’t know how to fix this issue.


#82

When I was struggling with the mail server, I wasn’t getting an error in the Spree admin portal (although the emails weren’t going through). What are your settings like in the Spree admin portal. Using the gmail SMTP mine were:

SMTP DOMAIN NAME: smtp.gmail.com
SMTP MAIL HOST: smtp.gmail.com
SMTP PORT: 587
SECURE CONNECTION TYPE: TLS
SMTP AUTHENTICATION TYPE: login
SMTP USERNAME: me@gmail.com
SMTP PASSWORD: *********

And I documented the process (struggle) here.

Maybe this SO post will help, as it looks like an error with a missing Ruby “symbol” assignment.


#83

@MikeiLL, The SO post help me to fix the error message and now I can send test email from admin page. Thanks for your help.

But I don’t receive confirmation email on enterprise creation.

Below, my email setting :

The same config was running on OFN 1.2

I checked the delayed_job.sh script which is running.
Then I don’t know what to check.
The delayed_job.sh command return this message :


#84

Possibly try installing and postfix and seeing if a mail sends from the command line. I’m not actually sure if the delayed job that sends the emails uses an external email program (postfix), but I found that getting a command line email working with my SMTP (gmail) account was a worthwhile endeavor in the troubleshooting process.

Also from what I remember I may have had to run sudo service monit restart, also documented about 2/3 of the way down this blog entry.


#85

@maikel I remember there was some talk of writing up a mail setup / troubleshooting page. Do you know if anything came of that?


#86

I install postfix and configure mail setting to use postfix. Then email testing is ok but confirmation email is not sent.

I tried to restart everything and finally, I receive the confirmation email.

On the confirmation email, the link is not providing https url :
Please click the link below to confirm your email and to continue setting up your profile.

Confirm this email address : http://testfrofn.cloudapp.net/enterprise/confirmation?confirmation_token=1UyYSS2Jqi9euCNYyxqk

Do you know where I should change this ?
And the URL of the logo img is in http on the email confirmation, maybe it should be in https ?
On my side, I open http port and nginx is doing redirection to https, then it’s not blocking.

Thanks


#87

Isn’t there a url field in the Spree configuration form?


#88

You are right, I update the field URL of the site in global parameter page. Now the pictures and links provide https links


#89

Great! I’m still looking for some insight as to why the Logo image (and some others) are missing on my admin page. Do you have any insight on that by any chance?


#90

I checked on my side and I don’t have this issue.
Is your folder and subfolders current/public have good permissions ?
On this directory, I have a link for assets which redirect to shared/assets

Did you see your web browser calling the logo on nginx error log ?
On nginx error log, I just have this error :

2015/11/24 15:22:38 [error] 1248#0: *370 open() “/home/openfood/apps/openfood/current/public/assets/loading.gif” failed (2: No such file or directory), client: 193.164.156.12, server: testfrofn.cloudapp.net, request: “GET /assets/loading.gif HTTP/1.1”, host: “testfrofn.cloudapp.net”, referrer: “https://testfrofn.cloudapp.net/admin/enterprises/nollet-epias/edit


#91

@RohanM No, we just have bits and pieces. For example Sending emails fails with 500 ArgumentError: Missing host to link to.

Should we do that in the deployment wiki?


#92

Good tip. I am getting an error that looks like it may be relevant:

2015/11/24 23:06:06 [error] 8915#0: *1908 upstream prematurely closed connection while reading response
header from upstream, client: 108.205.62.183, server: staging.usfoodcoop.org, request: "GET /logos
/original/missing.png HTTP/1.1", upstream: "http://unix:/home/ubuntu/apps/ofn_america/shared
/sock/unicorn.ofn_america.sock:/logos/original/missing.png", host: "staging.usfoodcoop.org", referrer: 
"https://staging.usfoodcoop.org/"

Looks like it may be an issue with server not allowing http connections, but from what I can see we are allowing connections on port 80. Would you mind comparing my /etc/nginx/sites-available/ofn_app_name file with yours:

    server {
    listen 443;
    server_name staging.usfoodcoop.org;
    root /home/ubuntu/apps/ofn_america/current/public;

    include ofn_america_ssl;


    try_files $uri/index.html $uri @unicorn;
    location @unicorn {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
        proxy_pass http://unicorn;
    }

    location ~ ^/(assets)/ {
        gzip_static on;
        expires max;
        add_header Cache-Control public;
        #add_header Last-Modified "";
        #add_header ETag "";
    }
    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 60;
}

Our default file looks like this:

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }
}

#93

My config files below :

upstream unicorn {
  server unix:/home/openfoodcanada/apps/openfoodcanada/shared/sock/unicorn.openfoodcanada.sock fail_timeout=0;
}

server {
  listen 80;
  server_name  www.testfrofn.cloudapp.net testfrofn.cloudapp.net;
  rewrite ^/(.*) https://testfrofn.cloudapp.net/$1 permanent;
}

server {
  listen 443;

  include openfoodcanada_ssl;

  server_name www.testfrofn.cloudapp.net;
  rewrite ^(.*) https://testfrofn.cloudapp.net/$1 permanent;
}

server {
  listen 443;
  server_name testfrofn.cloudapp.net;
  root /home/openfoodcanada/apps/openfoodcanada/current/public;

  include openfoodcanada_ssl;


  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }
  location ~ ^/(assets)/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    #add_header Last-Modified "";
    #add_header ETag "";
  }
  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 60;
}

Your default file should redirect to https
Don’t care about canada names, it’s because I used ofn_deployment canada-updates branch


#94

@MikeiLL, is your images missing are images about enterprises ?
I did an update of the OFN code from ansible script and I loose enterprises images.
These images are located under current/public/images. When an upgrade is done, the current directory is moved to released_old and then iamges are lost. I think this directory should be hosted under shared directory with a link to current directory like assets.


#95

Are you using AWS S3 for image storage? If not, might be worth setting that up.


#96

No, I’m using local storage, then the storage is under current/public/images.
If I run ansible playbook install.yml to upgrade version, then current directory is renamed released_old/ but under public sub directory, there is no image directory.

I just tried again to run install.yml playbook and I get the same result, logo and image of the entreprise is lost.
I copy the content of releases-old/2015-12-05-045103/public/images to current/public and I get back the images.
Then I think public/images should be relocated to shared directory and linked to public like assets directory.


#97

I’m also using local storage. Thanks for the suggestion. I’m not really clear on what the benefit of using S3 for the image storage would be. Caching?


#98

Will report back as soon as I have a chance to peel back the lid again.


#99

Using S3 to store the image will probably help in version upgrade. The other point is S3 could provide better performance than local storage and share the storage if we need more than one webserver.


#100

There’s a couple of strong reasons to use S3 for file storage:

  • S3 is cheaper (cost per storage, and also for data transfer) than hosting the images on a VPS
  • Hosting the images on S3 reduces the number of requests the web server has to handle, increasing its overall responsiveness