Back

[SOLVED] Custom SMTP Server in Console

  • 0
  • Self Hosted
paulanerl
1 Nov, 2023, 18:17

Also now I think this is related to my other support-question: https://discord.com/channels/564160730845151244/1168836797451747338

TL;DR
The user was experiencing issues with a custom SMTP server in the console. They discovered that the problem was caused by another service running on the same port and sometimes intercepting the API requests. They found a solution by making changes to the api.conf file. The fault was in the Apache config of the server. They also encountered a proxy error and received a notification in the Appwrite console. The user was advised to check their response in the PATCH SMTP request and make sure XHR is enabled. The discussion thread also mentioned a related support question about request types being filtered.
Drake
1 Nov, 2023, 18:25

what request types do you have filtered to?

paulanerl
1 Nov, 2023, 18:30

i do not have an active filter

Drake
1 Nov, 2023, 18:36

top right-ish, it looks like only HTML, CSS, something, something, and Web Scokets are enabled

Drake
1 Nov, 2023, 18:36

would you please enable XHR?

paulanerl
1 Nov, 2023, 18:38

sure

paulanerl
1 Nov, 2023, 18:44

I also got now this notification at the top right corner of appwrite console

Drake
1 Nov, 2023, 19:00

proxy....sounds like you have a proxy set up in front of appwrite. that could be the problem behind your realtime

Drake
1 Nov, 2023, 19:01

check out the response in that PATCH smtp request

paulanerl
1 Nov, 2023, 19:03

yeah I have a proxy error:

Status 502 Proxy Error VersionHTTP/1.1 Übertragen716 B (433 B Größe) Referrer Policystrict-origin-when-cross-origin Anfrage-PrioritätHighest DNS-AuflösungSystem

Drake
1 Nov, 2023, 19:03

for the SMTP request?

paulanerl
1 Nov, 2023, 19:04

message "The requested route was not found. Please refer to the API docs and try again." code 404 type "general_route_not_found" version "1.4.8" file "/usr/src/code/app/controllers/general.php" line 854 trace
0
file "/usr/src/code/vendor/utopia-php/framework/src/App.php" line 508 function "{closure}" args [] 1
file "/usr/src/code/vendor/utopia-php/framework/src/App.php" line 673 function "execute" class "UtopiaApp" type "->" args
0 {} 1 {} 2 {} 2
file "/usr/src/code/app/http.php" line 253 function "run" class "UtopiaApp" type "->" args
0 {} 1 {}

Drake
1 Nov, 2023, 19:05

FYI, it's best to wrap code in 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

paulanerl
1 Nov, 2023, 19:08
TypeScript
message    "The requested route was not found. Please refer to the API docs and try again."
code    404
type    "general_route_not_found"
version    "1.4.8"
file    "/usr/src/code/app/controllers/general.php"
line    854
trace    
0    
file    "/usr/src/code/vendor/utopia-php/framework/src/App.php"
line    508
function    "{closure}"
args    []
1    
file    "/usr/src/code/vendor/utopia-php/framework/src/App.php"
line    673
function    "execute"
class    "Utopia\\App"
type    "->"
args    
0    {}
1    {}
2    {}
2    
file    "/usr/src/code/app/http.php"
line    253
function    "run"
class    "Utopia\\App"
type    "->"
args    
0    {}
1    {}

ok so what does that mean?

paulanerl
1 Nov, 2023, 19:12

this was in the smtp request

Drake
1 Nov, 2023, 19:15

weird...i tested and it executed fine:

Drake
1 Nov, 2023, 19:15

maybe this problem is due to your reverse proxy too 🤷🏼‍♂️

paulanerl
1 Nov, 2023, 19:17

you mean the traefik wright?

paulanerl
3 Nov, 2023, 07:30

I now found a solution and fixed it 🙂

paulanerl
3 Nov, 2023, 07:31

The fault was in the apache config of the server.

paulanerl
3 Nov, 2023, 07:33

This was my api.conf file before changes:

TypeScript

<Macro APICertsPaths>
    SSLCertificateFile /etc/ssl/api-example.example/cert.pem
    SSLCertificateKeyFile /etc/ssl/api-example.example/key.pem
    SSLCertificateChainFile /etc/ssl/api-example.example/fullchain.pem
    SSLCACertificatePath /etc/ssl/api-example.example
    SSLCACertificateFile /etc/ssl/api-example.example/fullchain.pem
</Macro>

<VirtualHost *:80>
    ServerName api-example.example

    ServerAdmin webmaster@example.example

    Alias /robots.txt /var/www/html/robots.txt

    #für lets encrypt
    Alias /.well-known/acme-challenge/ /var/www/acme/.well-known/acme-challenge/
    <Directory "/var/www/acme/.well-known/acme-challenge">
        AllowOverride None
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        Require method GET POST OPTIONS
    </Directory>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
    RewriteCond %{REQUEST_URI} !^/robots.txt [NC]
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:443>
    ServerName api-example.example

    SSLEngine On
    Use APICertsPaths

    ProxyAddHeaders On
    #Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
    #Header set X-Frame-Options: "SAMEORIGIN"
    RequestHeader set X-FORWARDED-PROTOCOL https
    RequestHeader set X-Forwarded-Ssl on

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine on
    RewriteCond ${HTTP:Upgrade} websocket [NC]
    RewriteCond ${HTTP:Connection} upgrade [NC]
    RewriteRule .* "wss:/localhost:1080/$1" [P,L]

    ProxyPreserveHost On
    ProxyPass / http://localhost:1080/
    ProxyPassReverse / http://localhost:1080/

</VirtualHost>
paulanerl
3 Nov, 2023, 07:34

and this is the fixed api.conf file:

TypeScript
<Macro APICertsPaths>
    SSLCertificateFile /etc/ssl/api-example.example/cert.pem
    SSLCertificateKeyFile /etc/ssl/api-example.example/key.pem
    SSLCertificateChainFile /etc/ssl/api-example.example/fullchain.pem
    SSLCACertificatePath /etc/ssl/api-example.example
    SSLCACertificateFile /etc/ssl/api-example.example/fullchain.pem
</Macro>

<VirtualHost *:80>
    ServerName api-example.example

    ServerAdmin webmaster@example.example

    Alias /robots.txt /var/www/html/robots.txt

    #für lets encrypt
    Alias /.well-known/acme-challenge/ /var/www/acme/.well-known/acme-challenge/
    <Directory "/var/www/acme/.well-known/acme-challenge">
        AllowOverride None
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        Require method GET POST OPTIONS
    </Directory>
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
    RewriteCond %{REQUEST_URI} !^/robots.txt [NC]
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI}

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:443>
    ServerName api-example.example

    SSLEngine On
    SSLProxyEngine on
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off
    Use APICertsPaths

    ProxyAddHeaders On

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


    ProxyPassReverseCookieDomain  "localhost:10443"  "api-example.example"
    ProxyPreserveHost On
    ProxyPass / https://localhost:10443/ upgrade=websocket
    ProxyPassReverse / https://localhost:10443/

</VirtualHost>
paulanerl
3 Nov, 2023, 07:36

at the bottom of the files are the relevant changes, also for everybody struggling here at this point:

this link helped me a lot: https://github.com/appwrite/appwrite/discussions/4056

paulanerl
3 Nov, 2023, 07:39

I have to say in my case there was not just this fault, also another service was running on same port and sometimes the API request got to this different service - just FYI.

Best regards

Drake
3 Nov, 2023, 22:03

[SOLVED] Custom SMTP Server in Console

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more