###状況
簡易的なREST APIを作成し、ec2でデプロイしようとしてます。
appサーバとdbをdocker-compose upで起動後、
nginx.conf内のupstreamにappサーバのアドレスを記載し、
nginxを起動したのですが、動きません。
以下にエラー内容、概要、原因に該当しそうなコードを記載いたします。
今までデプロイはやったことがなく、慣れていないことなので、
正直何がわかってないのかわからないような状態です。
非常に質問の仕方も下手だと思うので、
ご指摘等含めてどなたかご教示いただけないでしょうか。
###概要
webサーバ:nginx
appサーバ:gunicorn
db:mysql
フロント:React
バック:python(falconというフレームワークを使ってます。)
###エラー
nginx: [emerg] invalid host in upstream "http://0.0.0.0:8000/" in /etc/nginx/nginx.conf:39 nginx: configuration file /etc/nginx/nginx.conf test failed
###docker-compose.yml
version: '3' services: app-matsu: image: python-api-1 build: context: . dockerfile: DockerFile ports: - 8000:8000 volumes: - ./python-api-1:/python-api-1/work networks: - common_link db-matsu: hostname: my-mysql build: context: ./mysql dockerfile: DockerFile ports: - 3306:3306 volumes: - ./mysql/initdb.d:/docker-entrypoint-initdb.d - ./mysql/conf.d:/etc/mysql/conf.d environment: MYSQL_DATABASE: sample_db MYSQL_USER: user MYSQL_PASSWORD: PASSWORD MYSQL_ROOT_PASSWORD: rootpassword TZ: Asia/Tokyo networks: - common_link networks: common_link: external: true
###docker-compose upで出るログ
Creating back-portfolio_app-matsu_1 ... done Creating back-portfolio_db-matsu_1 ... done Attaching to back-portfolio_db-matsu_1, back-portfolio_app-matsu_1 db-matsu_1 | Initializing database db-matsu_1 | 210603 16:43:56 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. db-matsu_1 | 210603 16:43:56 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.62) starting as process 67 ... db-matsu_1 | 210603 16:43:57 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. db-matsu_1 | 210603 16:43:57 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.5.62) starting as process 73 ... app-matsu_1 | [2021-06-03 16:43:57 +0900] [1] [INFO] Starting gunicorn 20.1.0 app-matsu_1 | [2021-06-03 16:43:57 +0900] [1] [INFO] Listening at: http://0.0.0.0:8000 (1) app-matsu_1 | [2021-06-03 16:43:57 +0900] [1] [INFO] Using worker: sync app-matsu_1 | [2021-06-03 16:43:57 +0900] [9] [INFO] Booting worker with pid: 9 ~中略~ db-matsu_1 | 210603 16:43:57 [Note] mysqld (mysqld 5.5.62) starting as process 83 ... db-matsu_1 | 210603 16:43:57 [Note] Plugin 'FEDERATED' is disabled. db-matsu_1 | 210603 16:43:57 InnoDB: The InnoDB memory heap is disabled db-matsu_1 | 210603 16:43:57 InnoDB: Mutexes and rw_locks use GCC atomic builtins db-matsu_1 | 210603 16:43:57 InnoDB: Compressed tables use zlib 1.2.11 db-matsu_1 | 210603 16:43:57 InnoDB: Using Linux native AIO db-matsu_1 | MySQL init process in progress... db-matsu_1 | 210603 16:43:57 InnoDB: Initializing buffer pool, size = 128.0M db-matsu_1 | 210603 16:43:57 InnoDB: Completed initialization of buffer pool db-matsu_1 | InnoDB: The first specified data file ./ibdata1 did not exist: db-matsu_1 | InnoDB: a new database to be created! db-matsu_1 | 210603 16:43:57 InnoDB: Setting file ./ibdata1 size to 10 MB db-matsu_1 | InnoDB: Database physically writes the file full: wait... db-matsu_1 | 210603 16:43:57 InnoDB: Log file ./ib_logfile0 did not exist: new to be created db-matsu_1 | InnoDB: Setting log file ./ib_logfile0 size to 5 MB db-matsu_1 | InnoDB: Database physically writes the file full: wait... db-matsu_1 | 210603 16:43:57 InnoDB: Log file ./ib_logfile1 did not exist: new to be created db-matsu_1 | InnoDB: Setting log file ./ib_logfile1 size to 5 MB db-matsu_1 | InnoDB: Database physically writes the file full: wait... db-matsu_1 | InnoDB: Doublewrite buffer not found: creating new db-matsu_1 | InnoDB: Doublewrite buffer created db-matsu_1 | InnoDB: 127 rollback segment(s) active. db-matsu_1 | InnoDB: Creating foreign key constraint system tables db-matsu_1 | InnoDB: Foreign key constraint system tables created db-matsu_1 | 210603 16:43:57 InnoDB: Waiting for the background threads to start db-matsu_1 | MySQL init process in progress... db-matsu_1 | 210603 16:43:58 InnoDB: 5.5.62 started; log sequence number 0 db-matsu_1 | 210603 16:43:58 [Warning] 'user' entry 'root@my-mysql' ignored in --skip-name-resolve mode. db-matsu_1 | 210603 16:43:58 [Warning] 'user' entry '@my-mysql' ignored in --skip-name-resolve mode. db-matsu_1 | 210603 16:43:58 [Warning] 'proxies_priv' entry '@ root@my-mysql' ignored in --skip-name-resolve mode. db-matsu_1 | 210603 16:43:58 [Note] Event Scheduler: Loaded 0 events db-matsu_1 | 210603 16:43:58 [Note] mysqld: ready for connections. db-matsu_1 | Version: '5.5.62' socket: '/tmp/mysql.sock' port: 0 MySQL Community Server (GPL) db-matsu_1 | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. db-matsu_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it. db-matsu_1 | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. db-matsu_1 | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. db-matsu_1 | 210603 16:44:00 [Warning] 'proxies_priv' entry '@ root@my-mysql' ignored in --skip-name-resolve mode. db-matsu_1 | 210603 16:44:00 [Warning] 'proxies_priv' entry '@ root@my-mysql' ignored in --skip-name-resolve mode. db-matsu_1 | db-matsu_1 | /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/schema.sql db-matsu_1 | db-matsu_1 | db-matsu_1 | 210603 16:44:00 [Note] mysqld: Normal shutdown db-matsu_1 | db-matsu_1 | 210603 16:44:00 [Note] Event Scheduler: Purging the queue. 0 events db-matsu_1 | 210603 16:44:00 InnoDB: Starting shutdown... db-matsu_1 | 210603 16:44:02 InnoDB: Shutdown completed; log sequence number 1600142 db-matsu_1 | 210603 16:44:02 [Note] mysqld: Shutdown complete db-matsu_1 | db-matsu_1 | db-matsu_1 | MySQL init process done. Ready for start up. db-matsu_1 | db-matsu_1 | 210603 16:44:02 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled db-matsu_1 | 210603 16:44:02 [Note] mysqld (mysqld 5.5.62) starting as process 1 ... db-matsu_1 | 210603 16:44:02 [Note] Plugin 'FEDERATED' is disabled. db-matsu_1 | 210603 16:44:02 InnoDB: The InnoDB memory heap is disabled db-matsu_1 | 210603 16:44:02 InnoDB: Mutexes and rw_locks use GCC atomic builtins db-matsu_1 | 210603 16:44:02 InnoDB: Compressed tables use zlib 1.2.11 db-matsu_1 | 210603 16:44:02 InnoDB: Using Linux native AIO db-matsu_1 | 210603 16:44:02 InnoDB: Initializing buffer pool, size = 128.0M db-matsu_1 | 210603 16:44:02 InnoDB: Completed initialization of buffer pool db-matsu_1 | 210603 16:44:02 InnoDB: highest supported file format is Barracuda. db-matsu_1 | 210603 16:44:02 InnoDB: Waiting for the background threads to start db-matsu_1 | 210603 16:44:03 InnoDB: 5.5.62 started; log sequence number 1600142 db-matsu_1 | 210603 16:44:03 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 db-matsu_1 | 210603 16:44:03 [Note] - '0.0.0.0' resolves to '0.0.0.0'; db-matsu_1 | 210603 16:44:03 [Note] Server socket created on IP: '0.0.0.0'. db-matsu_1 | 210603 16:44:03 [Warning] 'proxies_priv' entry '@ root@my-mysql' ignored in --skip-name-resolve mode. db-matsu_1 | 210603 16:44:03 [Note] Event Scheduler: Loaded 0 events db-matsu_1 | 210603 16:44:03 [Note] mysqld: ready for connections. db-matsu_1 | Version: '5.5.62' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
###nginx.conf
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; include /etc/nginx/conf.d/*.conf; upstream falcon_app { server http://0.0.0.0:8000/; } server { listen 80 default_server; listen [::]:80 default_server; server_name kaishi.no.portfolio; root /home/ec2-user/front-portfolio/build; index index.html; include /etc/nginx/default.d/*.conf; location / { client_max_body_size 50M; add_header Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, Authorization, Accept, Content-Type"; add_header Access-Control-Allow-Credentials true; proxy_pass http://falcon_app; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
###他症状
gunicornを立ち上げているhttp://0.0.0.0:8000にアクセスしても何も反応がなく、そもそもappサーバが立ち上がってない気がします...
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/06/03 08:50