0

I getting problem with the connecting nginx server, postgresql and Matrix Synapse

  • Postgresql it is running see the systemctl status below . enter image description here -Synapse1 is the database and roshyara is user which I have already added in the postgresql .
  • hb_pga_conf files are as following
      1 # TYPE  DATABASE        USER            ADDRESS                 METHOD
      2 local   all             all                                     md5
      3
      4 # The same using local loopback TCP/IP connections.
      5 #
      6 # TYPE  DATABASE        USER            ADDRESS                 METHOD
      7 host    all             all             127.0.0.1/32            md5
      8 host    all             all             0.0.0.0/0               md5
      9 host    all             all             ::1/128                 md5
     10 # IPv4 local connections:
     11 host    all             all             127.0.0.1/32            md5
     12 host    all             all             172.19.0.0/16           md5

  • Synapse homeserver.yaml file is as follwoing
   1 # Configuration file for Synapse.
      2 #
      3 # This is a YAML file: see [1] for a quick introduction. Note in particular
      4 # that *indentation is important*: all the elements of a list or dictionary
      5 # should have the same indentation.
      6 #
      7 # [1] https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html
      8 #
      9 # For more information on how to configure Synapse, including a complete accounting of
     10 # each option, go to docs/usage/configuration/config_documentation.md or
     11 # https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html
     12
     13 #server_name: "192.168.11.88"
     14 server_name: 192.168.11.88
     15 #
     16 pid_file: /root/synapse1/homeserver.pid
     17 #web_client: True
     18 #soft_file_limit: 0
     19 #
     20 #type: http
     21 #tls: true
     22 #x_forwarded: true
     23
     24 #user_directory:
     25     enabled: true
     26
     27 database:
     28   name: psycopg2
     29   args:
     30     user: roshyara
     31     password: 12345678
     32     database: synapse1
     33     host: 127.0.0.1
     34     port: 5432
     35     cp_min: 5
     36     cp_max: 10
     37     #database: /root/synapse1/homeserver.db
     38     # seconds of inactivity after which TCP should send a keepalive message to the server
     39     keepalives_idle: 10
     40
     41     # the number of seconds after which a TCP keepalive message that is not
     42     # acknowledged by the server should be retransmitted
     43     #keepalives_interval: 10
     44
     45     # the number of TCP keepalives that can be lost before the client's connection
     46     # to the server is considered dead
     47 #    keepalives_count: 3
     48
     50 log_config: "/root/synapse1/192.168.11.88.log.config"
     51 media_store_path: /root/synapse/media_store
     52 #registration_shared_secret: ";6NfAHoYP#xt3vQpi-o^4-8rJDeBnujn*rLdk-R7h6:,&~rjm."
     53 report_stats: true
     54 macaroon_secret_key: "D=:YD_lc_^;QhiKhj.iGV&@AEW3rmcna6rAq9O~.2=b6^lwyr6"
     55 form_secret: "r,:c#PA6PEwk3B9e7d=AKjUD--Iw#X+zB4R_C^4aB.zWGZt+K1"
     56 signing_key_path: "/root/synapse/matrix.ginmbh.de.signing.key"
     57 trusted_key_servers:
     58   - server_name: "matrix.org"
     59

-synapse is also running enter image description here

  • Nginx sever is also runnung enter image description here

  • nginx setting is as follwoing /etc/nginx/nginx.conf

 1 #user
      2 user  nginx;
      3 worker_processes  auto;
      4 # include config file
      5
      6 #include /etc/nginx/conf.d/*.conf;
      7 #
      8 #load_module modules/ngx_postgres_module.so;
      9
     10 #
     11 error_log  /var/log/nginx/error.log notice;
     12 pid        /var/run/nginx.pid;
     13
     14
     15 events {
     16     worker_connections  1024;
     17 }
     18
     19
     20 http {
     21     include       /etc/nginx/mime.types;
     22     default_type  application/octet-stream;
     23
     24     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
     25                       '$status $body_bytes_sent "$http_referer" '
     26                       '"$http_user_agent" "$http_x_forwarded_for"';
     27
     28     access_log  /var/log/nginx/access.log  main;
     29
     30     sendfile        on;
     31     #tcp_nopush     on;
     32
     33     keepalive_timeout  65;
     34
     35     include /etc/nginx/conf.d/*.conf;
     36 }

  • /etc/nginx/conf.d/matrix.conf file
 1 #
      2 server {
      3     listen 443 ssl http2;
      4     listen [::]:443 ssl http2;
      5
      6     # For the federation port
      7     listen 8448 ssl http2 default_server;
      8     listen [::]:8448 ssl http2 default_server;
      9
     10     server_name 192.168.11.88;
     11         #ssl on;
     12     ssl_certificate /etc/letsencrypt/live/matrix.ginmbh.de/fullchain.pem;
     13     ssl_certificate_key /etc/letsencrypt/live/matrix.ginmbh.de/privkey.pem;
     14
     15     #location ~ ^(/_matrix|/_synapse/static) {
     16     location /  {
     17         # note: do not add a path (even a single /) after the port in `proxy_pass`,
     18         # otherwise nginx will canonicalise the URI and cause signature verification
     19         # errors.
     20         proxy_pass http://localhost:8008;
     21         proxy_set_header X-Forwarded-For $remote_addr;
     22         proxy_set_header X-Forwarded-Proto $scheme;
     23         proxy_set_header Host $host;
     24
     25         # Nginx by default only allows file uploads up to 1M in size
     26         # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
     27         client_max_body_size 50M;
     28
     29     # Synapse responses may be chunked, which is an HTTP/1.1 feature.
     30     proxy_http_version 1.1;
     31     }
     32 }

-tcp connection

(env) [root@matrix-clon synapse1]# netstat -tunpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      822/sshd
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      2459/postmaster
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      1105/nginx: master
tcp        0      0 0.0.0.0:8448            0.0.0.0:*               LISTEN      1105/nginx: master
tcp6       0      0 :::22                   :::*                    LISTEN      822/sshd
tcp6       0      0 :::443                  :::*                    LISTEN      1105/nginx: master
tcp6       0      0 :::8448                 :::*                    LISTEN      1105/nginx: master
tcp6       0      0 :::9090                 :::*                    LISTEN      1/systemd
(env) [root@matrix-clon synapse1]#

(env) [root@matrix-clon synapse1]# ps aux |grep nginx
root        1105  0.0  0.0  44768   920 ?        Ss   11:52   0:00 nginx: master process /usr/sbin/nginx
nginx       1106  0.0  0.1  77860  7688 ?        S    11:52   0:02 nginx: worker process
nginx       1107  0.0  0.1  77468  5212 ?        S    11:52   0:00 nginx: worker process
root        1202  0.0  0.0   7352   908 pts/1    S+   11:52   0:00 tail -f /var/log/nginx/error.log
root        2615  0.0  0.0  12136  1152 pts/0    S+   12:35   0:00 grep --color=auto nginx

port is also open

(env) [root@matrix-clon synapse1]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: cockpit dhcpv6-client http https ssh
  ports: 8448/tcp 5432/tcp
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:
(env) [root@matrix-clon synapse1]#

However, nginx is showing the follwoing error . What can I do now and how can I test which connection is creating problem?

2023/02/12 12:08:38 [error] 1106#0: *249 connect() failed (111: Connection refused) while connecting to upstream, client: ::1, server: 192.168.11.88, request: "GET /_synapse/admin/v1/register HTTP/1.1", upstream: "http://[::1]:8008/_synapse/admin/v1/register", host: "localhost:8448"
2023/02/12 12:08:38 [warn] 1106#0: *249 upstream server temporarily disabled while connecting to upstream, client: ::1, server: 192.168.11.88, request: "GET /_synapse/admin/v1/register HTTP/1.1", upstream: "http://[::1]:8008/_synapse/admin/v1/register", host: "localhost:8448"
2023/02/12 12:08:38 [error] 1106#0: *249 connect() failed (111: Connection refused) while connecting to upstream, client: ::1, server: 192.168.11.88, request: "GET /_synapse/admin/v1/register HTTP/1.1", upstream: "http://127.0.0.1:8008/_synapse/admin/v1/register", host: "localhost:8448"
2023/02/12 12:08:38 [warn] 1106#0: *249 upstream server temporarily disabled while connecting to upstream, client: ::1, server: 192.168.11.88, request: "GET /_synapse/admin/v1/register HTTP/1.1", upstream: "http://127.0.0.1:8008/_synapse/admin/v1/register", host: "localhost:8448"
2023/02/12 12:11:52 [error] 1106#0: *294 connect() failed (111: Connection refused) while connecting to upstream, client: 10.176.8.89, server: 192.168.11.88, request: "GET /_matrix/static/ HTTP/2.0", upstream: "http://127.0.0.1:8008/_matrix/static/", host: "192.168.11.88"
2023/02/12 12:11:52 [warn] 1106#0: *294 upstream server temporarily disabled while connecting to upstream, client: 10.176.8.89, server: 192.168.11.88, request: "GET /_matrix/static/ HTTP/2.0", upstream: "http://127.0.0.1:8008/_matrix/static/", host: "192.168.11.88"
2023/02/12 12:11:52 [error] 1106#0: *294 connect() failed (111: Connection refused) while connecting to upstream, client: 10.176.8.89, server: 192.168.11.88, request: "GET /_matrix/static/ HTTP/2.0", upstream: "http://[::1]:8008/_matrix/static/", host: "192.168.11.88"
2023/02/12 12:11:52 [warn] 1106#0: *294 upstream server temporarily disabled while connecting to upstream, client: 10.176.8.89, server: 192.168.11.88, request: "GET /_matrix/static/ HTTP/2.0", upstream: "http://[::1]:8008/_matrix/static/", host: "192.168.11.88"

  • installed nginx
  • installed postgresql
  • installed matrix synapse
  • created homeserver.yaml
  • now the nginx server is showing upstream server is not available

0 Answers0