Elixir Phoenix production server has issue with Letsencrypt renewal - web-deployment

I have a site built with Elixir Phoenix frame work. The website runs fine in both dev and prod mode.
When the phoenix server is running in dev mode, I have no issue renewingLet's Encrypt certificate, but when the exact same app is running in prod mode, I keep getting permission error when trying to renew. Please noted that I am talking about the exact same app, on the same FreeBSD server, executed by the same user - both command without sudo. The only difference is MIX_ENV=prod
I also noted that in prod mode, the phoenix server log an 404 error when Letsencrypt is trying to access my priv/static/.well-known/acme-challenge/(some-unique-string) My basic set up for phoenix + letsencrypt is detailed in this blog post
The question is: how is phoenix server treating directory/file permission differently between `prod' and 'dev' mode?
Using Elixir 1.2.4 and Phoenix 1.1.4
UPDATE:
Folks, since LetsEncrypt and Phoenix framework evolve rapidly, the issue I listed above is no longer an issue if you are using the latest cerbot from LetsEncrypt and Phoenix 1.2.0
This is not necessary an answer to the original questions though.

I've solved it, by using a route, instead of file:
scope "/.well-known", MyApp do
get "/acme-challenge/:challenge", AcmeChallengeController, :show
end
And a simple controller..
defmodule AcmeChallengeController do
use MyApp, :controller
def show(conn, %{"challenge" => "the_random_file_name"}) do
send_resp(conn, 200, "TheHashInTheFile")
end
def show(conn, _) do
send_resp(conn, 200, "Not valid")
end
end
This is hardcoded, compiled and faster then sending files, but, it would be also possible to use some kind of key/value store, and manage (add/delete) the the challenges from within the UI without re-deployment.

Related

AWS Wordpress Loadbalancer 502 Bad Gateway

For the last few days I've been working on deploying a new Wordpress site using this AWS Workshop. (which is very well written)
https://catalog.us-east-1.prod.workshops.aws/workshops/3de93ad5-ebbe-4258-b977-b45cdfe661f1/en-US
I have completed everything exactly how they describe in the guide. But I am running into an issue with the launch configuration. When I copy the UserData scrip in the guide, update the variables with the info for my site and deploy the config I get a 502 error. For testing a wrote a basic scrip that just echos "Hello World" which works as expected. Does anyone have any guidance to resolve this issue?
Thanks!

Artifactory UI monitoring service status showing "online (0 of 0 nodes)" after migrating JFrog platform to new virtual machine

I have an existing JFrog/Artifactory Pro 7.27.10 RPM-based install (on a CentOS 8 VM) that I recently migrated to a new (Centos Stream 8 VM) running JFrog/Artifactory Pro 7.31.13 (also installed via RPM).
After copying my existing master.key file from the original JFrog install to the relevant directory, I started up the Artficatory Pro service on the new VM and proceeded to migrate my data using the "Simple migration with downtime" process described in this JFrog whitepaper. Everything worked fine, Artifactory is running as expected on the new VM and all my data appears good. I moved my frontend proxy DNS aliases over to the new VM and shut down the proxy on the old VM.
One problem I am now noticing is that in the Artifactory admin UI, the Monitoring > Service Status now doesn't appear to report my Artifactory/JFrog platform microservice status any more. It does show Artifactory with the correct backend IP address (running on port 8082) but then the "Status" shows "Online" with (0 of 0 nodes) and the ">" fold down arrow shows nothing when clicked. I went back to my old Artifactory instance and checked and it was still showing the single node with all of the individual JFrog platform service statuses properly.
My guess is that I missed something in the migration process and/or something else needs to be configured to allow the services to show up on the monitoring page, however I'm at a loss as to what this is or even where to look for it. I looked through the system.full-template.yaml but nothing seems obvious there. And while the Artifactory docs are usually fairly comprehensive, the page about monitoring doesn't seem to give much insight about how this is configured or what to do if it's missing. Also not sure if the initial startup of Artifactory on the new VM before I migrated by data affected how the monitoring was configured such that it now doesn't work with the imported data (unfortunately I didn't check the monitoring UI in the new VM before I did the data migration so I can't say for sure if it was initially working)
A couple of other details which may be relevant:
when migrating my VM, I kept the same (FQDN) hostname, but the IP address was different
I used the same frontend (nginx) proxy configurations on both the old/new VMs though I'm not sure if this is relevant here or not.
With the exception of going from CentOS 8 to Stream 8, the VM configurations themselves should be nearly identical as I create them from a kickstart (which was only updated for the new stream repo paths). Again not sure whether this is relevant at all here.
Any ideas on where I should be looking to figure out how to fix this?

ACORE API, assistance with errors and deployment

I'm having trouble with setting up ACORE API's and then having them work on a website.
Background:
Azerothcore running 3.3.5 on a debian standalone server, this has the Database, Core files and runs both the world and auth server basically a standard setup that is shown in the how-to wiki.
I also have a standalone web server, on the same subnet, but it's a separate server running linux and normal web server stuff, this has a wordpress installation with azerothcore plugin for user signup etc.
I'm trying to add the player map (https://github.com/azerothcore/playermap) and the ACORE-API set of functions (server status, arenastats, BG que and wow statistics) (https://github.com/azerothcore/acore-api)
Problem:
I understand the acore-api must be run in a container (docker or whatever) on the server, which I have done and it binds to port 3000, I can then go to the local ip:3000 and it brings up this error. (all db's etc are connecting and soap is working)
error 404 when navigating to IP:3000
I do get a few errors when running NPM install seen here: I'm not sure if they would be causing any issues or not.
screenshot of NPM errors on install
But further that, when I put say 'serverstatus' on the webserver (separate server) and configure the config.ts file I can't seem to get anything to display.
I'm not sure what I'm doing wrong but is the same scenario for all of the different functions for the acore-api
How are these meant to be installed and function? I feel I'm missing a vital step.
Likewise, with PLAYERMAP I have edited the comm_conf.php and set the realmd_id, but when loading the page, I do get the map, but the uptime is missing and no players are shown?
Could someone assist if possible?
Seems like an issue with NodeJS version. Update your NodeJS to latest LTS version 16.13.0 (https://nodejs.org)

Delayed_Job NoMethodError when using Nginx

I'm having trouble implementing the Delayed_Job_Active_Record gem in my Production Environment with Nginx. The user submits a 'Contact Us' form, the relevant controller action is called by Nginx and the following line of code fails:
#contact.delay.send_contact_form
Where the relevant method is:
def send_contact_form
ContactMailer.contact_us(self).deliver
end
Development Env: OK
On my local machine I have the pages served by Webrick. Everything runs fine, the delayed jobs go through the 'Delayed_Jobs' table and emails are sent.
Production Env - Rails Console: OK
On the server if I create #contact and call #contact.delay.send_contact_form manually, the delayed job goes through the delayed job table and email is sent.
Production Env - Webrick: OK
On the server if I start up a rails Webrick server I and enter the data for #contact via the web interface and then submit the job goes through the delayed job table and email is sent.
Production Env - Nginx: ERROR
The application is currently served by Nginx.
If I visit the interface via Nginx and enter the data for #contact and submit the page hangs.
The Production Log gives the following error on the controller action, (referencing the line above):
NoMethodError (undefined method `delay' for #< Contact:0x000000052962b0>)
I have also confirmed that the versions of Rails, Ruby and the Delayed_Job_Active_Record and Daemons gems are the same in both environments.
Any help would be greatly appreciated as i've been stuck on this one for a while. I want to find a solution that works with Nginx and which gives me the same functionality as 'Delayed Job'.
Thanks.
It turns out the problem was with Unicorn/Nginx not being restarted upon deployment of code updates, leaving them with incorrect configurations. The problem also occurred when adding Devise and other gems to the application.
The solution initially was to log into the VPS shell after a deployment, (via Capistrano) and run the following:
Restart Unicorn:
/etc/init.d/unicorn_esg stop
/etc/init.d/unicorn_esg start
Where *unicorn_esg* is the Unicorn reference to the application used in my deploy.rb configuration.
Restart Nginx:
sudo service nginx restart
The next step would be to incorporate this into the end of the deploy.rb script so it is automatically run at the end of each deployment.

How to deploy WordPress with Capistrano on shared host without sudo

In the pursuit of a more professional WordPress dev and deployment environment I am trying to use Capistrano to deploy from my local dev environment to staging and production servers but I can't quite get it to work.
I am on Site5 shared hosting and am deploying to one server with two different domains - staging.example.com and example.com.
I have used https://github.com/markjaquith/WP-Stack as a basis and have added
set :user, "myserveruser" to my config.rb file as the connection didn't work without that.
Running cap deploy:checktells me "You appear to have all necessary dependencies installed" and I can run cap deploy:setup which successfully connects to staging and production creating releases and shared directories etc.
The problem comes when I run cap deploy. Everything seams to work fine until I am prompted for a sudo password. This is not a normal login prompt though and does not allow me to type a password. As I am on a shared host I don't have sudo access anyway.
Its similar to this problem Capistrano is hanging when prompting for SUDO password to an Ubuntu box but the solutions didn't fix all my issues.
I have set default_run_options[:pty] = true which I seam to need but still get the sudo prompt.
I am using passwordless ssh so Capistrano is able to connect and do everything it needs to do without prompting for a password and I am also using an SSH config file to handel agent forwarding so the server can also connect to my git repository. I have confirmed this is working.
I have found other people having similar problems - Capistrano using sudo even with "set :use_sudo, false" - etc but none of the solutions have worked.
I am using default_run_options[:pty] = true and have tried using set :use_sudo, false and default_run_options[:shell] = false but I still have the same issue.
You can view my Terminal output here - http://pastebin.com/5xZmCnyA
I am seriously going crazy! Any help would be greatly appreciated!!!
Cheers
You can't run setup without sudo. That's the only part that REQUIRES sudo, because it makes a directory public_html/staging.exposecreative.org, in your case...
That step shouldn't be required, you can make that directory yourself (assuming you have permission)..
The problem you will face however is that the shared host will expect your index.php to be directly in public_html, for that to work you'd need write permission to whatever directory public_html is in, which your shared host won't allow (almost certainly)
The line default_run_options[:pty] = true has to do with whether Capistrano pretends to be an interactive shell or not. Many commands (sudo included) use this to determine if they should bother asking the user for input, or if they are part of an automated process (
in which case there's no way to ask for input)
My advice (as Capistrano maintainer) - don't try this on a shared host, it almost certainly won't work. (Sorry, their limitations, not ours)
I wrote an extensive post on how to deploy WordPress with Capistrano on a shared host (Bluehost). I use the Roots/Bedrock stack and it only took me about 20 minutes to get up and running.
I made a WordPress development stack using Shipit JS instead of Capistrano because I'm not comfortable with Ruby. Maybe that can help. Feel free to use it and/or post some issues if needed. Regards.
WP-Jungle / Bonzai

Resources