docker-bookstack icon indicating copy to clipboard operation
docker-bookstack copied to clipboard

servername _ causes invalid helo for smtp mail sending

Open s00500 opened this issue 5 years ago • 24 comments

Hi everyone,

I have been using this image and want to use a smtp server with it. the problem is though that somehow the servername is an underscore and that causes an invalid helo message...

I have found this in the nginx configuration:

server_name _;

Apparently a similar problem exists also on the nextcloud image and has been reported as an issue

https://github.com/nextcloud/server/issues/14941

Is there a easy workaroud or some better configuration to fix this ?

Greetings and thanks for the otherwise awesome image!

s00500 avatar Nov 10 '20 21:11 s00500

Thanks for opening your first issue here! Be sure to follow the issue template!

github-actions[bot] avatar Nov 10 '20 21:11 github-actions[bot]

Ok, I just realised that the nginx config is placed in the persistent /config dir and can easily be edited, nevermind, maybe this could be added to the docs to save some other people some searchtime ?

s00500 avatar Nov 10 '20 21:11 s00500

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 11 '20 02:12 github-actions[bot]

Could this be added to the docs ?

s00500 avatar Dec 11 '20 07:12 s00500

@s00500

+1 for adding to Docs

Thanks for posting, this helped me

chonnymon avatar Feb 26 '21 16:02 chonnymon

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 03 '21 02:08 github-actions[bot]

please add this to the docs!

s00500 avatar Aug 03 '21 06:08 s00500

What are we changing in the docs? Let me know so I can make some updates...

homerr avatar Aug 07 '21 19:08 homerr

A note on troubleshooting emails:

If you get an INVALID HELO error when trying to send an email using bookstack SMTP try the following solution: Link the /config folder to a local volume, run the container, then navigate to the volume -> nginx folder and edit the nginx.conf file. remove the line server_name _; or replace it with your domain: server_name my.wiki.domain.com;

s00500 avatar Aug 14 '21 11:08 s00500

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 14 '21 02:09 github-actions[bot]

Not stale!

s00500 avatar Sep 14 '21 12:09 s00500

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Oct 15 '21 02:10 github-actions[bot]

@homerr can you please add the note ?

s00500 avatar Oct 15 '21 06:10 s00500

@s00500 can you try setting server_name _; and then replace your php location block with the following:

    location ~ ^(.+\.php)(.*)$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;

        fastcgi_param SERVER_NAME $http_host;
    }

Let me know if this works. I'm seeing this method to be somewhat common practice.

p.s. I'm not positive that SERVER_NAME should be set to $http_host, there might be a better value, but I'm wanting to ensure that setting SERVER_NAME via fastcgi_param works correctly. If so, we may be able to implement an environment variable as a permanent fix.

nemchik avatar Nov 01 '21 20:11 nemchik

@nemchik I can confirm that this solution works for me

s00500 avatar Nov 02 '21 17:11 s00500

@nemchik I can confirm that this solution works for me

Great! Thanks for testing that. I will look into the best way to implement setting fastcgi_param SERVER_NAME <something here>;

This may be tied into a larger effort I'm working on with our nginx base image, which would mean it could be on hold for some time. I'll try to determine if it makes sense to go that direction, or to make an individual method for this image (which could roll out much sooner). Until then, you should have a working solution. We'll keep info updated in this issue as progress is made.

nemchik avatar Nov 02 '21 18:11 nemchik

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 03 '21 02:12 github-actions[bot]

NOT STALE !!!!!!!!!!!!!!!!!!!

s00500 avatar Dec 03 '21 08:12 s00500

@s00500 is your ! ok?

j0nnymoe avatar Dec 03 '21 08:12 j0nnymoe

My install is fine, and I also documented the solution in the beginning of this issue and tested alternative approaches successfully, but my initial request of having this issue documented is not fulfilled as this is still undocumented, making this issue the only place where it is documented. Keeping it open will at least make it easier to find for people. Is there any way you could disable the stale-bot here ? or pin the issue ?

s00500 avatar Dec 03 '21 08:12 s00500

So yes after dismissing the stale-bot for the 5th time on such a simple issue my keyboard seems to have suffered from it haha (just joking, please do not take personal ;-) )

s00500 avatar Dec 03 '21 08:12 s00500

I believe @nemchik is working on our nginx based images which will include a fix for this issue. I'll check if there is a flag that will make the bot ignore this issue.

j0nnymoe avatar Dec 03 '21 08:12 j0nnymoe

So yes after dismissing the stale-bot for the 5th time on such a simple issue my keyboard seems to have suffered from it haha (just joking, please do not take personal ;-) )

Ha no worries :-) - bot should leave this issue alone now.

j0nnymoe avatar Dec 03 '21 08:12 j0nnymoe

Just to follow up, https://github.com/linuxserver/docker-baseimage-alpine-nginx/pull/84 this is the work being done, but it does not yet include a change to handle this specific issue.

I'm still investigating the difference between fastcgi_param SERVER_NAME $http_host; and fastcgi_param SERVER_NAME $host;

Based on my research it seems $host is the correct value to use and should be safe as a default value. Ref: https://www.php.net/manual/en/reserved.variables.server.php which links to http://www.faqs.org/rfcs/rfc3875.html#:~:text=4.1.14.%20%20SERVER_NAME

See also: https://stackoverflow.com/a/15414811/1384186 tl;dr

  • $http_host is set by the request header, and can contain a port.
  • $host contains the value of $http_host without the port (unless $http_host is somehow not set, then it falls back to $server_name which we define in the nginx config as _).

there is a separate SERVER_PORT parameter nginx already passes to php, and the CGI spec defines SERVER_NAME in a way that does not mention including the port.

nemchik avatar Dec 03 '21 15:12 nemchik