我在AWS上使用Elastic Beanstalk进行了简单的应用程序设置。我正在使用Node.Js
我写了一个简单的条件,在我的代理服务器Nginx上将每个HTTP请求重定向到HTTPS。但是在每次部署之后,我总是必须进入我的ssh实例来放回这个小条件。怎样才能使这个过程不那么痛苦?
我的文件夹结构
程序my_app -ebextensions --nginx --- conf.d ---- my_config_prox.conf
这是我的文件内容
files:
"/etc/nginx/conf.d/portfolio_proxy.conf":
mode: "000644"
owner: root
group: root
content: |
upstream nodejs {
server 127.0.0.1:8081;
keepalive 256;
}
server {
listen 80;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
access_log /var/log/nginx/access.log main;
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if ($http_x_forwarded_proto != 'https') {
return 301 https://$host$request_uri;
}
}
location /elb-status {
access_log off;
return 200;
}
gzip on;
gzip_comp_level 4;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xm$
"/opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash -xe
rm -f "/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"
service nginx stop
service nginx start
container_commands:
removeconfig:
command: "rm -f /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf"
有没有人可以帮助我? 在AWS上使用nod应用程序设置重定向是一种好方法吗?