#pproxy.pl setup; presumes Rocky Linux 8.6 set up as Pleroma server #the script and nginx config changes should work as-is on any Linux #but the commands for installing prerequisites and setting up the service #definition are pretty RHEL/CentOS/Rocky 8-specific #see: https://docs-develop.pleroma.social/backend/configuration/how_to_serve_another_domain_for_webfinger/ #you should first configure your Pleroma server to match that document #IMPORTANT: you will need to replace the following two strings throughout #this document: # #YOURHOST = the name your Pleroma instance is configured to think of itself as # i.e. "host.domain.tld" # #YOURDOMAIN = the name you want your instance to appear to be # i.e. "domain.tld" yum install -y perl cpan useradd pproxy su - pproxy cpan -Ti HTTP::Proxy chmod u+w /home/pproxy/perl5/lib/perl5/HTTP/Proxy.pm nano -w /home/pproxy/perl5/lib/perl5/HTTP/Proxy.pm #CHANGE: host => '127.0.0.1', # chmod u-w /home/pproxy/perl5/lib/perl5/HTTP/Proxy.pm nano -w proxy.pl #ADD: #!/usr/bin/perl use HTTP::Proxy qw( :log ); use HTTP::Proxy::HeaderFilter::simple; use HTTP::Proxy::BodyFilter::simple; my $domain = "YOURDOMAIN"; my $host = "YOURHOST"; my $proxy = HTTP::Proxy->new( port => 4001 ); my $ua = LWP::UserAgent->new(timeout => 10); $ua->proxy(['http'], 'http://127.0.0.1:4000/'); $proxy->agent($ua); my $bodyfilter = HTTP::Proxy::BodyFilter::simple->new( sub { my ( $self, $dataref, $message, $protocol, $buffer ) = @_; if(true == $message->headers->content_is_text) { ${ $_[1] } =~ s/\@${host}/\@${domain}/gi; } } ); $proxy->push_filter( mime => undef, response => $bodyfilter ); $proxy->start; # #test run /usr/bin/perl proxy.pl nano -w /etc/systemd/system/pproxy.service #ADD: [Unit] Description=pproxy After=network.target [Service] Type=simple User=pproxy WorkingDirectory=/home/pproxy ExecStart=/bin/bash -lc "/usr/bin/perl /home/pproxy/proxy.pl" TimeoutSec=15 Restart=always [Install] WantedBy=multi-user.target # systemctl enable --now pproxy.service service nginx stop nano -w /etc/nginx/conf.d/pleroma.conf #CHANGE: upstream phoenix_direct { server 127.0.0.1:4000 max_fails=5 fail_timeout=60s; } upstream phoenix { server 127.0.0.1:4001 max_fails=5 fail_timeout=60s; } #ADD: location ~ ^/.well-known/webfinger { if ( $args ~* ^resource=acct:(.*)@YOURDOMAIN$ ) { set $args resource=acct:$1@YOURHOST; } proxy_pass http://phoenix; } location ~ ^/ostatus_subscribe { if ( $args ~* ^acct=(.*)@YOURDOMAIN$ ) { set $args acct=$1@YOURHOST; } proxy_pass http://phoenix; } location /static { proxy_pass http://phoenix_direct; } location /api/v1/accounts/update_credentials { proxy_pass http://phoenix_direct; } # service nginx start