Reputation: 387
I wanted to implement basic http auth for my symfony elastic beanstalk PHP application. I allready found this link where it is explained for an other php project and tweaked it a little bit for my symfony needs.
files:
"/etc/httpd/conf.d/allow_override.conf":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
<Directory /var/www/html/www/ />
AllowOverride AuthConfig
</Directory>
"/etc/httpd/conf.d/auth.conf":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
<Directory /var/www/html/www/ />
AuthType Basic
AuthName "Myproject Prototype"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
"/etc/httpd/.htpasswd":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
admin:lala
Problem is: I am not sure what directory to set there. I tried:
But none of this is working. All I get are some Error 503.
Upvotes: 1
Views: 1194
Reputation: 103
When you are using Symfony, your directory will be: /var/www/html/web/
You also have to set the AllowOverride to All. Your File would look like this:
files:
"/etc/httpd/conf.d/allow_override.conf":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
<Directory /var/www/html/web/>
AllowOverride All
</Directory>
"/etc/httpd/conf.d/auth.conf":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
<Directory /var/www/html/web/>
AuthType Basic
AuthName "Myproject Prototype"
AuthUserFile /etc/httpd/.htpasswd
Require valid-user
</Directory>
"/etc/httpd/.htpasswd":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
admin:$apr1$e2ahR98m$oQ9tE8rqr/l5XPr3cCZYK1
Upvotes: 1