Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

virtualhost - third level domain to folder with proxy using https

I am working on having third level domains redirected to a folder using apache proxy.

I am starting from the following code:

<VirtualHost *:80>
    ServerName blog.example.com
    ErrorLog /var/www/blog.example.com/log/error.log
    CustomLog /var/www/blog.example.com/log/requests.log combined
    ProxyPass "/"  "http://example.com/blog/"
    ProxyPassReverse "/"  "http://example.com/blog/"
</VirtualHost>

My domain is using letsencrypt to provide ssl so for the domain i have two vhosts. How do I best integrate this proxy configuration in my current configuration so that it works on https?

VHost example.conf

<VirtualHost *:80>
    ServerName example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/
    <Directory /var/www/html/ >
        Allow from All
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =example.com [OR]
    RewriteCond %{SERVER_NAME} =www.example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

VHost example.com-le-ssl.conf

ServerName example.com
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html
    <Directory /var/www/html>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ErrorDocument 404 /custom404.html
    ErrorDocument 500 /custom500.html
    ErrorDocument 502 /custom500.html
    ErrorDocument 503 /custom500.html
    ErrorDocument 504 /custom500.html

    <Files "custom404.html">
            <If "-z%{ENV:REDIRECT_STATUS}">
                    RedirectMatch 404 ^/custom404.html$
            </If>
    </Files>
    <Files "custom500.html">
            <If "-z %{ENV:REDIRECT_STATUS}">
                    RedirectMatch 500 ^/custom500.html$
            </If>
    </Files>

    ProxyPreserveHost On
    SSLProxyEngine On
    ProxyPass /store https://example.com:4343
    ProxyPassReverse /store https://example.com:4343

    Include /etc/letsencrypt/options-ssl-apache.conf
    SetEnv ENV_TYPE "dev"
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
question from:https://stackoverflow.com/questions/65917460/third-level-domain-to-folder-with-proxy-using-https

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...