AWS上のAmazon Linuxにnginxをインストールして、nginx.confを編集したのですが、EC2ダッシュボードに表示されているIPに接続できませんでした。
(apacheだと表示されます。)
nginx.conf
conf
1user nginx nginx; 2#worker_processes 2; 3#worker_rlimit_nofile 1024; 4#worker_cpu_affinity 01 10; 5 6error_log /var/log/nginx/error.log warn; 7pid /var/run/nginx.pid; 8 9 10events { 11 multi_accept off; 12 worker_connections 1024; 13 use epoll; 14} 15 16 17http { 18 19 include /etc/nginx/mime.types; 20 default_type application/octet-stream; 21 22 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 23 '$status $body_bytes_sent "$http_referer" ' 24 '"$http_user_agent" "$http_x_forwarded_for"'; 25 26 log_format backend '$http_x_forwarded_for - $remote_user [$time_local] "$request" ' 27 '$status $body_bytes_sent "$http_referer" ' 28 '"$http_user_agent"'; 29 30 access_log /var/log/nginx/access.log main; 31 32 server_tokens off; 33 server_name_in_redirect off; 34 port_in_redirect off; 35 36 client_max_body_size 3m; 37 client_body_buffer_size 256k; 38 39 sendfile on; 40 tcp_nopush on; 41 42 keepalive_timeout 15; 43 44 gzip on; 45 gzip_static on; 46 gzip_http_version 1.0; 47 gzip_proxied any; 48 gzip_vary on; 49 gzip_comp_level 1; 50 gzip_types text/plain 51 text/xml 52 text/css 53 text/javascript 54 application/xhtml+xml 55 application/xml 56 application/rss+xml 57 application/atom_xml 58 application/javascript 59 application/x-javasript 60 application/x-httpd-php 61 application/json 62 image/x-icon 63 image/bmp 64 image/png 65 image/gif 66 image/jpeg 67 image/jpg; 68 gzip_disable "MSIE[1-6]\."; 69 70 proxy_buffering on; 71 proxy_buffer_size 8k; 72 proxy_buffers 100 8k; 73 #proxy_cache_path /var/cache/nginx/proxy_temp levels=1:2 74 # keys_zone=czone:15m max_size=512m inactive=7d; 75 #proxy_temp_path /var/tmp/nginx 1 2; 76 proxy_cache_valid 200 302 2h; 77 proxy_cache_valid 301 4h; 78 proxy_cache_valid any 1m; 79 proxy_cache_use_stale error timeout invalid_header updating 80 http_500 http_502 http_503 http_504; 81 82 # set header 83 proxy_set_header Host $host; 84 proxy_set_header X-Real-IP $remote_addr; 85 proxy_set_header X-Remote-Addr $remote_addr; 86 proxy_set_header X-Forwarded-Host $host; 87 proxy_set_header X-Forwarded-Server $host; 88 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 89 90 # backend 91 upstream backend { 92 ip_hash; 93 server 127.0.0.1:80; 94 } 95 96 include /etc/nginx/conf.d/*.conf; 97} 98
EC2のダッシュボードのセキュリティグループの設定で80,8080,82は
許可してあります。nginx.confのどのあたりを修正すべきでしょうか。
[ec2-user@ip-172-31-xx-xx init.d]$ sudo curl 127.0.0.1:80
curl: (7) Failed to connect to 127.0.0.1 port 80: Connection refused
’
[ec2-user@ip-172-31-xx-xx init.d]$ sudo netstat -tlnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 2142/rpcbind
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2317/sshd
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 2372/postmaster
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 19248/master
tcp 0 0 0.0.0.0:58024 0.0.0.0:* LISTEN 2163/rpc.statd
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 18545/mysqld
tcp 0 0 :::44590 :::* LISTEN 2666/java
tcp 0 0 :::111 :::* LISTEN 2142/rpcbind
tcp 0 0 :::8080 :::* LISTEN 2666/java
tcp 0 0 :::22 :::* LISTEN 2317/sshd
tcp 0 0 :::55807 :::* LISTEN 2163/rpc.statd
回答2件
あなたの回答
tips
プレビュー