github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/docker/apache-basic_auth_proxy (about) 1 # Copyright 2017 Intel Corporation 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # ------------------------------------------------------------------------------ 15 16 # Description: 17 # Builds an image to be used in testing REST API behavior behind a proxy with 18 # Basic Authentication. Redirects from 'basic_auth_proxy/sawtooth' to 19 # 'rest-api:8008' with both HTTP and HTTPS. 20 # 21 # Build: 22 # $ cd sawtooth-core/docker 23 # $ docker build . \ 24 # -f apache-basic_auth_proxy \ 25 # -t apache-basic_auth_proxy 26 # 27 # Run: 28 # $ cd sawtooth-core 29 # $ docker run -v $(pwd):/project/sawtooth-core \ 30 # -v /var/run/docker.sock:/var/run/docker.sock \ 31 # apache-basic_auth_proxy 32 33 FROM ubuntu:xenial 34 35 RUN apt-get update \ 36 && apt-get install -y apache2 \ 37 && a2enmod proxy_http \ 38 && a2enmod headers \ 39 && a2enmod ssl 40 41 RUN openssl req -x509 -nodes -days 7300 -newkey rsa:2048 \ 42 -keyout /tmp/.ssl.key -out /tmp/.ssl.crt \ 43 -subj /C=US/ST=MN/L=Mpls/O=Sawtooth/CN=basic_auth_proxy 44 45 RUN echo "sawtooth:\$apr1\$cyAIkitu\$Cv6M2hHJlNgnVvKbUdlFr." >/tmp/.password 46 47 RUN echo "\ 48 \n\ 49 ServerName basic_auth_proxy\n\ 50 ServerAdmin sawtooth@sawtooth\n\ 51 DocumentRoot /var/www/html\n\ 52 \n\ 53 " >>/etc/apache2/apache2.conf 54 55 RUN echo "\ 56 <VirtualHost *:80>\n\ 57 </VirtualHost>\n\ 58 \n\ 59 <VirtualHost *:443>\n\ 60 SSLEngine on\n\ 61 SSLCertificateFile /tmp/.ssl.crt\n\ 62 SSLCertificateKeyFile /tmp/.ssl.key\n\ 63 RequestHeader set X-Forwarded-Proto \"https\"\n\ 64 </VirtualHost>\n\ 65 \n\ 66 <Location />\n\ 67 Options Indexes FollowSymLinks\n\ 68 AuthType Basic\n\ 69 AuthName \"Enter password\"\n\ 70 AuthUserFile \"/tmp/.password\"\n\ 71 Require user sawtooth\n\ 72 Require all denied\n\ 73 </Location>\n\ 74 \n\ 75 ProxyPass /sawtooth http://rest-api:8008\n\ 76 ProxyPassReverse /sawtooth http://rest-api:8008\n\ 77 RequestHeader set X-Forwarded-Path \"/sawtooth\"\n\ 78 \n\ 79 " >/etc/apache2/sites-enabled/000-default.conf 80 81 EXPOSE 80 82 EXPOSE 443 83 EXPOSE 8008 84 85 CMD ["apachectl start"]