Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用阿里云cdn证书报错:The change you wanted was rejected. #133

Open
bilinxing opened this issue Jul 21, 2021 · 7 comments
Open

Comments

@bilinxing
Copy link

docker镜像版本:tinyc/app-host:0.2.3
nginx配置:
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass http://127.0.0.1:8686;
}
nginx只开启了80端口,外面套了一层阿里云的cdn,证书通过阿里云的cdn申请和自动部署的

@tinyc-z
Copy link
Contributor

tinyc-z commented Jul 21, 2021

ApplicationController 里有一行代码,可以把注释去掉试试,记得重启 docker

skip_before_action :verify_authenticity_token

@bilinxing
Copy link
Author

注释去掉之后,docker起不来了
` -> 0.0004s

== 20181205180629 AddFeaturesToPkg: migrated (0.0005s) ========================

== 20190123090654 AddArchiveToApps: migrating =================================

-- add_column(:apps, :archived, :boolean, {:default=>false})

-> 0.0004s

== 20190123090654 AddArchiveToApps: migrated (0.0005s) ========================

== 20210119125335 AddExtInfoToPkgs: migrating =================================

-- add_column(:pkgs, :ext_info, :string)

-> 0.0005s

== 20210119125335 AddExtInfoToPkgs: migrated (0.0020s) ========================

== 20210121074133 RemoveSoftDelete: migrating =================================

== 20210121074133 RemoveSoftDelete: migrated (0.0200s) ========================

[....] Starting nginx: nginx[ ok .

Puma starting in single mode...

  • Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas

  • Min threads: 3, max threads: 10

  • Environment: production

/app/config/initializers/rack.rb:3: warning: already initialized constant Rack::Multipart::Parser::BUFSIZE

/usr/local/bundle/gems/rack-2.2.3/lib/rack/multipart/parser.rb:12: warning: previous definition of BUFSIZE was here

  • Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop

[....] Starting nginx: nginx[ ok .

Puma starting in single mode...

  • Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas

  • Min threads: 3, max threads: 10

  • Environment: production

/app/config/initializers/rack.rb:3: warning: already initialized constant Rack::Multipart::Parser::BUFSIZE

/usr/local/bundle/gems/rack-2.2.3/lib/rack/multipart/parser.rb:12: warning: previous definition of BUFSIZE was here

! Unable to load application: ArgumentError: Before process_action callback :verify_authenticity_token has not been defined

Traceback (most recent call last):

64: from /usr/local/bundle/bin/puma:23:in `<main>'

63: from /usr/local/bundle/bin/puma:23:in `load'

62: from /usr/local/bundle/gems/puma-3.12.6/bin/puma:10:in `<top (required)>'

61: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/cli.rb:80:in `run'

60: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/launcher.rb:186:in `run'

59: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/single.rb:98:in `run'

58: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/runner.rb:147:in `load_and_bind'

57: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/configuration.rb:245:in `app'

56: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/configuration.rb:320:in `load_rackup'

55: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'

54: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'

53: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'

52: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'

51: from config.ru:3:in `block in <main>'

50: from config.ru:3:in `require_relative'

49: from /app/config/environment.rb:5:in `<top (required)>'

48: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/application.rb:361:in `initialize!'

47: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:60:in `run_initializers'

46: from /usr/local/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'

45: from /usr/local/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'

44: from /usr/local/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'

43: from /usr/local/lib/ruby/2.5.0/tsort.rb:347:in `call'

42: from /usr/local/lib/ruby/2.5.0/tsort.rb:347:in `each'

41: from /usr/local/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'

40: from /usr/local/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'

39: from /usr/local/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'

38: from /usr/local/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'

37: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:61:in `block in run_initializers'

36: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:32:in `run'

35: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:32:in `instance_exec'

34: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'

33: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/application/finisher.rb:69:in `each'

32: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:356:in `eager_load!'

31: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:475:in `eager_load!'

30: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:475:in `each'

29: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:477:in `block in eager_load!'

28: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:477:in `each'

27: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'

26: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:246:in `require_dependency'

25: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:334:in `depend_on'

24: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:356:in `require_or_load'

23: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:37:in `load_interlock'

22: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies/interlock.rb:13:in `loading'

21: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'

20: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies/interlock.rb:14:in `block in loading'

19: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:37:in `block in load_interlock'

18: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:378:in `block in require_or_load'

17: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `require'

16: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:257:in `load_dependency'

15: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `block in require'

14: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `require'

13: from /app/app/controllers/udid_controller.rb:1:in `<top (required)>'

12: from /app/app/controllers/udid_controller.rb:2:in `<class:UdidController>'

11: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:202:in `block (2 levels) in <module:ClassMethods>'

10: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:95:in `_insert_callbacks'

 9: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:95:in `each'

 8: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:96:in `block in _insert_callbacks'

 7: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:203:in `block (3 levels) in <module:ClassMethods>'

 6: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:696:in `skip_callback'

 5: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:625:in `__update_callbacks'

 4: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:625:in `reverse_each'

 3: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:627:in `block in __update_callbacks'

 2: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:697:in `block in skip_callback'

 1: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:697:in `each'

/usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:701:in block (2 levels) in skip_callback': Before process_action callback :verify_authenticity_token has not been defined (ArgumentError)

@tinyc-z
Copy link
Contributor

tinyc-z commented Jul 21, 2021

注释去掉之后,docker起不来了
` -> 0.0004s

== 20181205180629 AddFeaturesToPkg: migrated (0.0005s) ========================

== 20190123090654 AddArchiveToApps: migrating =================================

-- add_column(:apps, :archived, :boolean, {:default=>false})

-> 0.0004s

== 20190123090654 AddArchiveToApps: migrated (0.0005s) ========================

== 20210119125335 AddExtInfoToPkgs: migrating =================================

-- add_column(:pkgs, :ext_info, :string)

-> 0.0005s

== 20210119125335 AddExtInfoToPkgs: migrated (0.0020s) ========================

== 20210121074133 RemoveSoftDelete: migrating =================================

== 20210121074133 RemoveSoftDelete: migrated (0.0200s) ========================

[....] Starting nginx: nginx[ ok .

Puma starting in single mode...

  • Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas
  • Min threads: 3, max threads: 10
  • Environment: production

/app/config/initializers/rack.rb:3: warning: already initialized constant Rack::Multipart::Parser::BUFSIZE

/usr/local/bundle/gems/rack-2.2.3/lib/rack/multipart/parser.rb:12: warning: previous definition of BUFSIZE was here

  • Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop

[....] Starting nginx: nginx[ ok .

Puma starting in single mode...

  • Version 3.12.6 (ruby 2.5.1-p57), codename: Llamas in Pajamas
  • Min threads: 3, max threads: 10
  • Environment: production

/app/config/initializers/rack.rb:3: warning: already initialized constant Rack::Multipart::Parser::BUFSIZE

/usr/local/bundle/gems/rack-2.2.3/lib/rack/multipart/parser.rb:12: warning: previous definition of BUFSIZE was here

! Unable to load application: ArgumentError: Before process_action callback :verify_authenticity_token has not been defined

Traceback (most recent call last):

64: from /usr/local/bundle/bin/puma:23:in `<main>'

63: from /usr/local/bundle/bin/puma:23:in `load'

62: from /usr/local/bundle/gems/puma-3.12.6/bin/puma:10:in `<top (required)>'

61: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/cli.rb:80:in `run'

60: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/launcher.rb:186:in `run'

59: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/single.rb:98:in `run'

58: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/runner.rb:147:in `load_and_bind'

57: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/configuration.rb:245:in `app'

56: from /usr/local/bundle/gems/puma-3.12.6/lib/puma/configuration.rb:320:in `load_rackup'

55: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'

54: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'

53: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'

52: from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'

51: from config.ru:3:in `block in <main>'

50: from config.ru:3:in `require_relative'

49: from /app/config/environment.rb:5:in `<top (required)>'

48: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/application.rb:361:in `initialize!'

47: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:60:in `run_initializers'

46: from /usr/local/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'

45: from /usr/local/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'

44: from /usr/local/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'

43: from /usr/local/lib/ruby/2.5.0/tsort.rb:347:in `call'

42: from /usr/local/lib/ruby/2.5.0/tsort.rb:347:in `each'

41: from /usr/local/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'

40: from /usr/local/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'

39: from /usr/local/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'

38: from /usr/local/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'

37: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:61:in `block in run_initializers'

36: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:32:in `run'

35: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/initializable.rb:32:in `instance_exec'

34: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'

33: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/application/finisher.rb:69:in `each'

32: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:356:in `eager_load!'

31: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:475:in `eager_load!'

30: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:475:in `each'

29: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:477:in `block in eager_load!'

28: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:477:in `each'

27: from /usr/local/bundle/gems/railties-5.2.4.4/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'

26: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:246:in `require_dependency'

25: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:334:in `depend_on'

24: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:356:in `require_or_load'

23: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:37:in `load_interlock'

22: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies/interlock.rb:13:in `loading'

21: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'

20: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies/interlock.rb:14:in `block in loading'

19: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:37:in `block in load_interlock'

18: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:378:in `block in require_or_load'

17: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `require'

16: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:257:in `load_dependency'

15: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `block in require'

14: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/dependencies.rb:291:in `require'

13: from /app/app/controllers/udid_controller.rb:1:in `<top (required)>'

12: from /app/app/controllers/udid_controller.rb:2:in `<class:UdidController>'

11: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:202:in `block (2 levels) in <module:ClassMethods>'

10: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:95:in `_insert_callbacks'

 9: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:95:in `each'

 8: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:96:in `block in _insert_callbacks'

 7: from /usr/local/bundle/gems/actionpack-5.2.4.4/lib/abstract_controller/callbacks.rb:203:in `block (3 levels) in <module:ClassMethods>'

 6: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:696:in `skip_callback'

 5: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:625:in `__update_callbacks'

 4: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:625:in `reverse_each'

 3: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:627:in `block in __update_callbacks'

 2: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:697:in `block in skip_callback'

 1: from /usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:697:in `each'

/usr/local/bundle/gems/activesupport-5.2.4.4/lib/active_support/callbacks.rb:701:in block (2 levels) in skip_callback': Before process_action callback :verify_authenticity_token has not been defined (ArgumentError)

哈哈哈,这么尴尬,那要不换个写法,在config/application.rb加入以下配置

config.action_controller.default_protect_from_forgery = false

@bilinxing
Copy link
Author

我放弃了,登录态用http,非登录态用https。 另外我还发现docker里目录权限问题,nginx用www-data用户启动的,然后上传的的文件所有者是root,导致下载文件的时候403无权限。所以上传的文件写磁盘的时候是puma进程完成的么,看到puma进程是root用户运行的。

@tinyc-z
Copy link
Contributor

tinyc-z commented Jul 22, 2021

我放弃了,登录态用http,非登录态用https。 另外我还发现docker里目录权限问题,nginx用www-data用户启动的,然后上传的的文件所有者是root,导致下载文件的时候403无权限。所以上传的文件写磁盘的时候是puma进程完成的么,看到puma进程是root用户运行的。

但是,权限是给的 -rw-r--r-- ,所以 ng 下载文件不会出现这个问题才对的哦,我测试和其他人使用也并没遇到你说的这个问题,是不是哪里搞错了?

@bilinxing
Copy link
Author

可能是因为我把data目录映射到阿里云oss导致的,把nginx改成root用户运行就可以。另外想问下可以自定安装包的下载链接么,因为我把上传文件的目录映射到oss,相当于文件都上传到oss上了。如果可以自定义下载链接,就可以直接从oss下载了,虽然我给服务器套了cdn,但是只为了方便上证书,服务器的回源带宽还是很低的。如果能直接从oss下载,速度会快很多。

@tinyc-z
Copy link
Contributor

tinyc-z commented Jul 22, 2021

可能是因为我把data目录映射到阿里云oss导致的,把nginx改成root用户运行就可以。另外想问下可以自定安装包的下载链接么,因为我把上传文件的目录映射到oss,相当于文件都上传到oss上了。如果可以自定义下载链接,就可以直接从oss下载了,虽然我给服务器套了cdn,但是只为了方便上证书,服务器的回源带宽还是很低的。如果能直接从oss下载,速度会快很多。

或许你要的答案这里有
#131

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants