docker上でnginxのコンテナを起動することはできるのですが、接続すると、502 Bad Gatewayとなってしまします。nginxのエラーログを確認したところ、以下のようなエラーが出ました。
puma.sockが存在しないというふうに言われてしまいます。しかし、確認するとしっかり存在しています。解決できる方がいたら、回答をよろしくお願いします。
2020/01/29 12:33:03 [crit] 7#7: *12 connect() to unix:///my_song/tmp/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.128.1, server: example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:///my_song/tmp/sockets/puma.sock:/500.html", host: "localhost", referrer: "http://localhost/"
puma.rb
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } threads threads_count, threads_count port ENV.fetch("PORT") { 3000 } environment ENV.fetch("RAILS_ENV") { "development" } plugin :tmp_restart bind "unix://#{Rails.root}/tmp/sockets/puma.sock" ``` nginx.conf ```ここに言語を入力 # upstream unicorn { # server unix:/var/www/html/${ProjectDir}/tmp/unicorn.sock; # } upstream my_song { server my_song:3000; } server { listen 80; server_name localhost; access_log /var/log/nginx/homepage_access.log; error_log /var/log/nginx/homepage_error.log; location / { #proxy_set_header Host cody-tube.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-CSRF-Token $http_x_csrf_token; proxy_set_header X-Forwarded-Proto https; #これ追加 proxy_redirect off; proxy_pass http://my_song; } } ``` nginxのdockerfile ```ここに言語を入力 FROM nginx:1.15.8 RUN rm -f /etc/nginx/conf.d/* # Nginxの設定ファイルをコンテナにコピー ADD nginx.conf /etc/nginx/conf.d/my_song.conf #Nginx起動 CMD /usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf ``` dockerfile ```ここに言語を入力 FROM ruby:2.6.3 RUN apt-get update -qq && \ apt-get install -y build-essential \ sox \ vim \ libsox-fmt-mp3 \ libpq-dev \ nodejs RUN mkdir /my_song WORKDIR /my_song ADD ./Gemfile /my_song/Gemfile ADD ./Gemfile.lock /my_song/Gemfile.lock RUN bundle install ADD . /my_song RUN mkdir -p tmp/sockets ``` docker-compose.yml ```ここに言語を入力 version : '3' services: db: image: mysql:5.7 environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: root volumes: - ./docker/db/data:/var/lib/mysql ports: - "3306:3306" web: tty: true stdin_open: true build: . command: /bin/sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" volumes: - .:/my_song ports: - "3000:3000" links: - db server: build: context: containers/nginx volumes: - ./nginx/log:/var/log/nginx - public-data:/my_song/public ports: - 80:80 depends_on: - web volumes: public-data: tmp-data: log-data: db-data: ```
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。