postal icon indicating copy to clipboard operation
postal copied to clipboard

Setup fast server fails with no host and respawns

Open DTS-Mike opened this issue 7 years ago • 11 comments

I have tried multiple attempts to get postal configured to know my fast server setup. I put in the fast server IP and set the enable to true but I can’t get it setup. When I go to the URL for it, click.dtschurch.com, I get the timeout error and not hello like I should.

When doing net stat I don’t see that the server is listening to port 5010 & 5011.

I did the let’s Encrypt command line from the open and click document but postal does not configure the fast server to be accessible. How do I setup my ngixn to Listen on those ports?

I think my issue is I’m in AWS and my public ip’s don’t work in ngixn but neither do the internal ips so I’m lost and need some help or examples if possible.

Thanks in advance!

DTS-Mike avatar Jul 19 '19 04:07 DTS-Mike

Here is my nginx config file:

server {

if ($host = postal.dtschurch.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot


listen [::]:80;
listen 0.0.0.0:80;
server_name postal.dtschurch.com;
return 301 https://$host$request_uri;

}

server { listen [::]:443 ssl; listen 0.0.0.0:443 ssl; root /opt/postal/app/public; server_name postal.dtschurch.com; # ssl_certificate ssl/postal.cert; # ssl_certificate_key ssl/postal.key;

# Generate using: openssl dhparam 4096 -out /etc/ssl/dhparam.pem
# ssl_dhparam /etc/ssl/dhparam.pem;

ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA512:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:ECDH+AESGCM:ECDH+AES256:DH$

location / {
   client_max_body_size 50M;
   try_files $uri $uri/index.html $uri.html @puma;
}

location /assets {
   add_header Cache-Control max-age=3600;
}

location @puma {
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_pass http://127.0.0.1:5000;
}

ssl_certificate /etc/letsencrypt/live/postal.dtschurch.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/postal.dtschurch.com/privkey.pem; # managed by Certbot

}

Here is my postal.yml web:

The host that the management interface will be available on

host: postal.dtschurch.com

The protocol that requests to the management interface should happen on

protocol: https

fast_server:

This can be enabled to enable click & open tracking on emails. It is disabled by

default as it requires a separate static IP address on your server.

enabled: true bind_address: 3.130.242.29

general:

This can be changed to allow messages to be sent from multiple IP addresses

use_ip_pools: false

main_db:

Specify the connection details for your MySQL database

host: postal.cbsk8gel8q6f.us-east-2.rds.amazonaws.com username: postal password: ******** database: postal

message_db:

Specify the connection details for your MySQL server that will be house the

message databases for mail servers.

host: postal.cbsk8gel8q6f.us-east-2.rds.amazonaws.com username: postal password: ******** prefix: postal

rabbitmq:

Specify the connection details for your RabbitMQ server.

host: 127.0.0.1 username: postal password: ***** vhost: /postal

dns:

Specifies the DNS record that you have configured. Refer to the documentation at

https://github.com/atech/postal/wiki/Domains-&-DNS-Configuration for further

information about these.

mx_records: - postal.dtschurch.com smtp_server_hostname: postal.dtschurch.com spf_include: spf.postal.dtschurch.com return_path: rp.postal.dtschurch.com route_domain: routes.postal.dtschurch.com track_domain: click.dtschurch.com

smtp:

Specify an SMTP server that can be used to send messages from the Postal management

system to users. You can configure this to use a Postal mail server once the

your installation has been set up.

host: postal.dtschurch.com port: 587 username: divine-technology-systems/dts-rock password: *******

Here is what ports are open using netstat -lpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1530/mysqld tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1591/nginx: master tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 1389/epmd tcp 0 0 0.0.0.0:5010 0.0.0.0:* LISTEN 1591/nginx: master tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 852/systemd-resolve tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1377/sshd tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 1591/nginx: master tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 2026/[postal] web.1 tcp 0 0 0.0.0.0:25672 0.0.0.0:* LISTEN 1098/beam.smp tcp6 0 0 :::80 :::* LISTEN 1591/nginx: master tcp6 0 0 :::4369 :::* LISTEN 1389/epmd tcp6 0 0 :::22 :::* LISTEN 1377/sshd tcp6 0 0 :::25 :::* LISTEN 2039/[postal] smtp. tcp6 0 0 :::443 :::* LISTEN 1591/nginx: master tcp6 0 0 :::5672 :::* LISTEN 1098/beam.smp udp 0 0 127.0.0.53:53 0.0.0.0:* 852/systemd-resolve udp 0 0 172.31.30.149:68 0.0.0.0:* 826/systemd-network raw6 0 0 :::58 :::* 7 826/systemd-network Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node PID/Program name Path unix 2 [ ACC ] SEQPACKET LISTENING 13461 1/init /run/udev/control unix 2 [ ACC ] STREAM LISTENING 23344 2063/systemd /run/user/1000/systemd/private unix 2 [ ACC ] STREAM LISTENING 23348 2063/systemd /run/user/1000/gnupg/S.dirmngr unix 2 [ ACC ] STREAM LISTENING 23349 2063/systemd /run/user/1000/gnupg/S.gpg-agent unix 2 [ ACC ] STREAM LISTENING 23350 2063/systemd /run/user/1000/gnupg/S.gpg-agent.browser unix 2 [ ACC ] STREAM LISTENING 23351 2063/systemd /run/user/1000/gnupg/S.gpg-agent.ssh unix 2 [ ACC ] STREAM LISTENING 23352 2063/systemd /run/user/1000/gnupg/S.gpg-agent.extra unix 2 [ ACC ] STREAM LISTENING 17574 990/irqbalance @irqbalance990.sock unix 2 [ ACC ] STREAM LISTENING 17463 1/init /var/lib/lxd/unix.socket unix 2 [ ACC ] STREAM LISTENING 23907 2020/[procodile] Po /tmp/postal/pids/procodile.sock unix 2 [ ACC ] STREAM LISTENING 17453 1/init /run/uuidd/request unix 2 [ ACC ] STREAM LISTENING 17455 1/init /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 17457 1/init /run/snapd.socket unix 2 [ ACC ] STREAM LISTENING 17459 1/init /run/snapd-snap.socket unix 2 [ ACC ] STREAM LISTENING 17451 1/init /run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 21471 1530/mysqld /var/run/mysqld/mysqld.sock unix 2 [ ACC ] STREAM LISTENING 17467 1/init @ISCSIADM_ABSTRACT_NAMESPACE unix 2 [ ACC ] STREAM LISTENING 13329 1/init /run/systemd/private unix 2 [ ACC ] STREAM LISTENING 13339 1/init /run/lvm/lvmpolld.socket unix 2 [ ACC ] STREAM LISTENING 13345 1/init /run/lvm/lvmetad.socket unix 2 [ ACC ] STREAM LISTENING 13355 1/init /run/systemd/journal/stdout

Any help would be greatly appreciated.

DTS-Mike avatar Jul 19 '19 12:07 DTS-Mike

The fast server handles itself with regard to web serving, you shouldn't need to put nginx in front of it primarily because it handles its own SSL certificates so configuring that manually could become arduous.

This means that the easiest way of setting up a Postal server with click tracking is to have two publicly accessible IP addresses. However there are a couple of issues somewhere where people have altered Postal to run both services from one IP address.

Also make sure that the IP addresses you are entering into postal.yml are actually available on the server with the ip a or ipconfig commands. You will find that AWS EC2 servers, for example, only see an internal IP address and the actual public-routable IP address is handled in Amazons side of things.

willpower232 avatar Jul 19 '19 13:07 willpower232

Ok so I have been messing with this for the last couple of days and think I am on the right track but its still not working.

When I put my fast server DNS name (click.dtschurch.com) in the browser I dont get the hello I have been dreaming of. It times out.

I have the dns name and the IP in the Postal.yaml file. I am hosted in aws so I have tried the public and the internal IP.

I also figured out that I had an issue with my second ethernet was not set in the ubuntu config but think I have that setup now to pull the internal IP:

root@ip-172-31-30-149:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000 link/ether 06:b8:21:18:4f:48 brd ff:ff:ff:ff:ff:ff inet 172.31.30.149/20 brd 172.31.31.255 scope global dynamic eth0 valid_lft 3358sec preferred_lft 3358sec inet6 fe80::4b8:21ff:fe18:4f48/64 scope link valid_lft forever preferred_lft forever 3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc mq state UP group default qlen 1000 link/ether 06:55:51:de:af:be brd ff:ff:ff:ff:ff:ff inet 172.31.28.83/20 brd 172.31.31.255 scope global dynamic eth1 valid_lft 3415sec preferred_lft 3415sec inet6 fe80::455:51ff:fede:afbe/64 scope link valid_lft forever preferred_lft forever

Any Suggestions?

DTS-Mike avatar Jul 21 '19 21:07 DTS-Mike

Ah yes, judging by our setup, you do have to manually assign the additional IP from AWS to your server.

Have you verified that the fast server is running and correctly bound with postal status and netstat -lnp?

Have you also assigned a secondary IP address to the Network Interface in your AWS EC2 console? Can you visit that IP address and see a "hello" message?

willpower232 avatar Jul 22 '19 11:07 willpower232

Hey Will, Thanks for all the help so far. I have setup the server with 2 Ethernet cards with Elastic Ip’s. The issue I am running into, I think I am at least, is a routing table issue due to both IP’s bring on the same subnet. Trying to learn as I go with this as I am new to smtp servers, Linux, and AWS. Needless to say I have rebooted about 100-125 times as it resets my routing table for connected eth cards.

When I run postal satus everything runs but the fast server will time out after 5 respawns.

When I do netstat -lnp I do not see the other ip. I am not sure what its supposed to look like using AWS but guess that I should see both local ip’s in the list and only see the main local ip.

I’m trying to piece a bunch of examples here and docs online.

DTS-Mike avatar Jul 24 '19 04:07 DTS-Mike

In our setup, we have two IPs on the elastic network interface that is connected to the server so they are both part of eth0. Both IP addresses are in the VPCs generous /16 subnet so there isn't any need for further configuring in AWS. Adding it to the server is another entry in the network config file so that the network adapter has one line for auto and another for static.

You should be able to see both IP addresses by running ip a or ipconfig, if you can't then thats probably where to start looking. I don't believe the routing tables need to be modified for this to work.

willpower232 avatar Jul 28 '19 19:07 willpower232

Ok I will look into that. I did not think that would work for some reason and have the old 2 ip’s need 2 eth adapters. Even though they are all virtual. I will focus on this as it’s one of the last steps before rolling out.

Also we have been working on displaying reports like the breakout of stats by day, week, and month. What is the best way to share this do others could use it?

DTS-Mike avatar Jul 28 '19 23:07 DTS-Mike

I may have misunderstood our setup but its something like this: https://askubuntu.com/questions/313877/how-do-i-add-an-additional-ip-address-to-etc-network-interfaces

Unfortunately Postal isn't that great at reporting on itself right now but there are tables of statistics if you look in the databases. These should be useful for counting send stats.

willpower232 avatar Jul 29 '19 08:07 willpower232

Thanks for all the help will. I have been having a doozy of time learning ip configs in aws. I think I am close. I am not using ifup like referenced above and using the defaulted netplan. From what i read I have created an additional yaml file for the second IP. Here are the 2 files: image

Primary File 50-cloud.init.yaml: image

Secondary File: image

Both External IP's now pull up our postal Web UI. I tried a couple different configurations for the netplan and not having much luck. I bricked my VM yesterday and spent a good part of the day recovering so now I am a bit more cautious. Here is my Postal File to show the Fast IP local aws IP: image

Any Thoughts or recommendation from anyone?

DTS-Mike avatar Jul 31 '19 05:07 DTS-Mike

Ok I found out what I did wrong. So after working through the above changes to my netplan setup files, I did not make the changes on the nginx side to reflect. Once I change the settings to:

nano -w /etc/nginx/sites-available/default and now mine looks like: image

I now have the most beautiful word hello ever! I will now close the thread but we might want to rename the topic as it is misleading.

DTS-Mike avatar Jul 31 '19 06:07 DTS-Mike

Glad you figured it out, my last comment would be to either remove or keep aware of the IPv6 lines in that nginx config as they might cause you similar problems when IPv6 becomes a bigger thing.

willpower232 avatar Jul 31 '19 09:07 willpower232