This commit is contained in:
邱博亞 2024-05-07 23:46:25 +08:00
parent 3234c94ea6
commit 0f93df5dc4
2 changed files with 7 additions and 7 deletions

View File

@ -8,12 +8,12 @@ class Admin::PlowController < ApplicationController
skip_before_action :verify_authenticity_token skip_before_action :verify_authenticity_token
def index def index
reverse_proxy "unix://#{Rails.root}/tmp/plow.sock", path: '/' do |config| reverse_proxy "unix://#{SocketFile}", path: '/' do |config|
end end
end end
def show def show
path = request.env['ORIGINAL_FULLPATH']#.gsub("/admin/plow", "") path = request.env['ORIGINAL_FULLPATH']#.gsub("/admin/plow", "")
reverse_proxy "unix://#{Rails.root}/tmp/plow.sock", path: path do |config| reverse_proxy "unix://#{SocketFile}", path: path do |config|
end end
end end
def setting def setting
@ -25,7 +25,7 @@ class Admin::PlowController < ApplicationController
def save_setting def save_setting
@setting.update_attributes(params[:plow_setting].permit!) @setting.update_attributes(params[:plow_setting].permit!)
if File.exist?(SocketFile) if File.exist?(SocketFile)
if @plow_pid if @plow_pid != 0
Process.kill(:INT, @plow_pid) Process.kill(:INT, @plow_pid)
end end
`rm #{SocketFile}` `rm #{SocketFile}`

View File

@ -1,4 +1,5 @@
class SiteCert class SiteCert
require 'fileutils'
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
mount_uploader :cert_file, AssetUploader #Public key mount_uploader :cert_file, AssetUploader #Public key
@ -35,13 +36,12 @@ class SiteCert
org_cert_file_name = self.cert_file.file.file.to_s org_cert_file_name = self.cert_file.file.file.to_s
cert_file_name = org_cert_file_name.sub(/.cer$/, '.crt') cert_file_name = org_cert_file_name.sub(/.cer$/, '.crt')
if org_cert_file_name != cert_file_name if org_cert_file_name != cert_file_name
if File.open(org_cert_file_name, 'r').read().match(/\A\s*---/) if File.read(org_cert_file_name).match(/\A\s*---/)
new_sf = CarrierWave::SanitizedFile.new(self.cert_file.file.move_to(cert_file_name)) FileUtils.cp(org_cert_file_name, cert_file_name)
else else
`openssl x509 --inform DER -in #{org_cert_file_name} --out #{cert_file_name}` `openssl x509 --inform DER -in #{org_cert_file_name} --out #{cert_file_name}`
new_sf = CarrierWave::SanitizedFile.new(cert_file_name)
end end
self.cert_file.cache!(new_sf) self.cert_file.retrieve_from_store!(File.basename(cert_file_name))
end end
cert_file_md5 = `openssl x509 -noout -modulus -in #{cert_file_name} | openssl md5` cert_file_md5 = `openssl x509 -noout -modulus -in #{cert_file_name} | openssl md5`
private_key_md5 = `openssl rsa -noout -modulus -in #{self.private_key.file.file} | openssl md5` private_key_md5 = `openssl rsa -noout -modulus -in #{self.private_key.file.file} | openssl md5`