Ruby on rails 在Rails上设置https和www重定向,并在Amazon Linux上的Apache上安装WordPress

Ruby on rails 在Rails上设置https和www重定向,并在Amazon Linux上的Apache上安装WordPress,ruby-on-rails,wordpress,apache,.htaccess,passenger,Ruby On Rails,Wordpress,Apache,.htaccess,Passenger,我想,重定向到 托管于的应用程序是Rails乘客应用程序 我在/var/www/html/blog中安装了WordPress,我将/blog化名为/var/www/html/blog,以便运行WordPress博客 然而,并不是所有事情都像我希望的那样工作: 现在: 这很好 不会的 不会的 正在控制台中引发如下异常:Mixed Content:the page at'https://example.com/blog/'已通过HTTPS加载,但请求的脚本不安全'http://xx.xx.xxx.x

我想,重定向到

托管于的应用程序是Rails乘客应用程序

我在
/var/www/html/blog
中安装了WordPress,我将
/blog
化名为
/var/www/html/blog
,以便运行WordPress博客

然而,并不是所有事情都像我希望的那样工作:

现在:

  • 这很好
  • 不会的
  • 不会的
  • 正在控制台中引发如下异常:
    Mixed Content:the page at'https://example.com/blog/'已通过HTTPS加载,但请求的脚本不安全'http://xx.xx.xxx.xxx/blog/wp-includes/js/wp-emoji-release.min.js?ver=4.6.1'. 此请求已被阻止;内容必须通过HTTPS提供。
    e@(索引):23
  • 运行正常,但我需要它重定向到**
  • 重定向到**
  • **第5点和第6点,这可能是因为我已经将WordPress URL设置为。如果我把它设为,我就会陷入一个无休止的循环

    我可以得到关于如何修改apache配置的建议吗

    /etc/httpd/conf/httpd.conf

    LoadModule passenger_module /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
    </IfModule>
    
    <VirtualHost *:80>
        ProxyPreserveHost On
        # Tell Apache and Passenger where your app's 'public' directory is
        DocumentRoot /var/www/example/public
        # Redirect / https://example.com
    
        PassengerRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
        PassengerFriendlyErrorpages on
    
        # JkMount /tc* node1
        # JkMount /intro* node1
    
        # Relax Apache security settings
        <Directory /var/www/example/public>
            RailsEnv production
            Allow from all
            Options -MultiViews
            # Uncomment this if you're on Apache >= 2.4:
            # Require all granted
    
            RewriteEngine On
            RewriteBase /
            RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] OR
            RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
        </Directory>
    
        <Directory /var/www/html/blog>
            PassengerEnabled off
            # Makes Wordpress's .htaccess file work
            AllowOverride all
        </Directory>
    </VirtualHost>
    
    Alias /blog /var/www/html/blog
    Alias /.well-known/acme-challenge/ /var/www/example/.well-known/acme-challenge/
    `
    
    LoadModule ssl_module modules/mod_ssl.so
    
    Listen 443
    
    SSLPassPhraseDialog  builtin
    
    SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
    SSLSessionCacheTimeout  300
    
    SSLMutex default
    
    SSLRandomSeed startup file:/dev/urandom  256
    SSLRandomSeed connect builtin
    
    SSLCryptoDevice builtin
    
    <VirtualHost _default_:443>
    
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    
    SSLProxyProtocol all -SSLv3
    
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
    
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    
    SetEnvIf User-Agent ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    
    CustomLog logs/ssl_request_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    # to run in dev mode
    RailsEnv production
    
    # Be sure to point to 'public'!
    DocumentRoot /var/www/example/public
    
    # define server details
    ServerName example.com
    #ServerAlias www.example.com
    
    # rails needs the header for its own processing
    RequestHeader set X_FORWARDED_PROTO 'https'
    
    # this is just passing a proxy to a localhost server
    # ProxyRequests Off
    # ProxyPreserveHost On
    # <Proxy *>
    # Order deny,allow
    # Allow from all
    # </Proxy>
    # ProxyPass / http://localhost/
    # ProxyPassReverse / http://localhost/
    
    #<Directory /var/www/html/blog>
    #  Options Indexes FollowSymLinks MultiViews
    #  AllowOverride All
    #  allow from all
    #  Require all granted
    #</Directory>
    
    </VirtualHost>  
    
    LoadModule passenger_module /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
    </IfModule>
    
    <VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ProxyPreserveHost On
        # Tell Apache and Passenger where your app's 'public' directory is
        DocumentRoot /var/www/example/public
    
        PassengerRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
        PassengerFriendlyErrorpages on
    
        # Relax Apache security settings
        <Directory /var/www/example/public>
            RailsEnv production
            Allow from all
            Options -MultiViews
            # Uncomment this if you're on Apache >= 2.4:
            # Require all granted
    
            RewriteEngine On
            RewriteCond %{SERVER_NAME} =www.adintern.com
            RewriteRule  ^(.*)$        https://adintern.com/$1 [L,R=301]
    
            RewriteCond %{HTTPS} off
            RewriteRule (.*)           https://adintern.com/$1
    
            RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
            RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
        </Directory>
    
        <Directory /var/www/html/blog>
            PassengerEnabled off
            # Makes Wordpress's .htaccess file work
            AllowOverride all
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    
    Alias /blog /var/www/html/blog
    Alias /.well-known/acme-challenge/ /var/www/example/.well-known/acme-challenge/
    
    LoadModule ssl_module modules/mod_ssl.so
    
    Listen 443
    
    SSLPassPhraseDialog  builtin
    
    SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
    SSLSessionCacheTimeout  300
    
    SSLMutex default
    
    SSLRandomSeed startup file:/dev/urandom  256
    SSLRandomSeed connect builtin
    
    SSLCryptoDevice builtin
    
    <VirtualHost _default_:443>
    
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    
    SSLProxyProtocol all -SSLv3
    
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/www.example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
    
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    
    CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    # to run in dev mode
    RailsEnv production
    
    # Be sure to point to 'public'!
    DocumentRoot /var/www/example/public
    
    # define server details
    ServerName example.com
    
    # rails needs the header for its own processing
    RequestHeader set X_FORWARDED_PROTO 'https'
    
    # this is just passing a proxy to a localhost server
    # ProxyRequests Off
    # ProxyPreserveHost On
    # <Proxy *>
    # Order deny,allow
    # Allow from all
    # </Proxy>
    # ProxyPass / http://localhost/
    # ProxyPassReverse / http://localhost/
    
    SSLCertificateChainFile /etc/letsencrypt/live/www.example.com/chain.pem
    
    </VirtualHost>
    

    我得到了以下用于将所有内容重定向到
    https://example.com
    ,但我无法为/blog获得https:

    httpd.conf

    LoadModule passenger_module /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
    </IfModule>
    
    <VirtualHost *:80>
        ProxyPreserveHost On
        # Tell Apache and Passenger where your app's 'public' directory is
        DocumentRoot /var/www/example/public
        # Redirect / https://example.com
    
        PassengerRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
        PassengerFriendlyErrorpages on
    
        # JkMount /tc* node1
        # JkMount /intro* node1
    
        # Relax Apache security settings
        <Directory /var/www/example/public>
            RailsEnv production
            Allow from all
            Options -MultiViews
            # Uncomment this if you're on Apache >= 2.4:
            # Require all granted
    
            RewriteEngine On
            RewriteBase /
            RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] OR
            RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
        </Directory>
    
        <Directory /var/www/html/blog>
            PassengerEnabled off
            # Makes Wordpress's .htaccess file work
            AllowOverride all
        </Directory>
    </VirtualHost>
    
    Alias /blog /var/www/html/blog
    Alias /.well-known/acme-challenge/ /var/www/example/.well-known/acme-challenge/
    `
    
    LoadModule ssl_module modules/mod_ssl.so
    
    Listen 443
    
    SSLPassPhraseDialog  builtin
    
    SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
    SSLSessionCacheTimeout  300
    
    SSLMutex default
    
    SSLRandomSeed startup file:/dev/urandom  256
    SSLRandomSeed connect builtin
    
    SSLCryptoDevice builtin
    
    <VirtualHost _default_:443>
    
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    
    SSLProxyProtocol all -SSLv3
    
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
    
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    
    SetEnvIf User-Agent ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    
    CustomLog logs/ssl_request_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    # to run in dev mode
    RailsEnv production
    
    # Be sure to point to 'public'!
    DocumentRoot /var/www/example/public
    
    # define server details
    ServerName example.com
    #ServerAlias www.example.com
    
    # rails needs the header for its own processing
    RequestHeader set X_FORWARDED_PROTO 'https'
    
    # this is just passing a proxy to a localhost server
    # ProxyRequests Off
    # ProxyPreserveHost On
    # <Proxy *>
    # Order deny,allow
    # Allow from all
    # </Proxy>
    # ProxyPass / http://localhost/
    # ProxyPassReverse / http://localhost/
    
    #<Directory /var/www/html/blog>
    #  Options Indexes FollowSymLinks MultiViews
    #  AllowOverride All
    #  allow from all
    #  Require all granted
    #</Directory>
    
    </VirtualHost>  
    
    LoadModule passenger_module /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
     PassengerRoot /usr/local/rvm/gems/ruby-2.3.3/gems/passenger-5.1.0
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
    </IfModule>
    
    <VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ProxyPreserveHost On
        # Tell Apache and Passenger where your app's 'public' directory is
        DocumentRoot /var/www/example/public
    
        PassengerRuby /usr/local/rvm/gems/ruby-2.3.3/wrappers/ruby
        PassengerFriendlyErrorpages on
    
        # Relax Apache security settings
        <Directory /var/www/example/public>
            RailsEnv production
            Allow from all
            Options -MultiViews
            # Uncomment this if you're on Apache >= 2.4:
            # Require all granted
    
            RewriteEngine On
            RewriteCond %{SERVER_NAME} =www.adintern.com
            RewriteRule  ^(.*)$        https://adintern.com/$1 [L,R=301]
    
            RewriteCond %{HTTPS} off
            RewriteRule (.*)           https://adintern.com/$1
    
            RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
            RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
        </Directory>
    
        <Directory /var/www/html/blog>
            PassengerEnabled off
            # Makes Wordpress's .htaccess file work
            AllowOverride all
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    
    Alias /blog /var/www/html/blog
    Alias /.well-known/acme-challenge/ /var/www/example/.well-known/acme-challenge/
    
    LoadModule ssl_module modules/mod_ssl.so
    
    Listen 443
    
    SSLPassPhraseDialog  builtin
    
    SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
    SSLSessionCacheTimeout  300
    
    SSLMutex default
    
    SSLRandomSeed startup file:/dev/urandom  256
    SSLRandomSeed connect builtin
    
    SSLCryptoDevice builtin
    
    <VirtualHost _default_:443>
    
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    
    SSLProxyProtocol all -SSLv3
    
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/www.example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder on
    SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
    
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    </Directory>
    
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
    
    CustomLog logs/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    # to run in dev mode
    RailsEnv production
    
    # Be sure to point to 'public'!
    DocumentRoot /var/www/example/public
    
    # define server details
    ServerName example.com
    
    # rails needs the header for its own processing
    RequestHeader set X_FORWARDED_PROTO 'https'
    
    # this is just passing a proxy to a localhost server
    # ProxyRequests Off
    # ProxyPreserveHost On
    # <Proxy *>
    # Order deny,allow
    # Allow from all
    # </Proxy>
    # ProxyPass / http://localhost/
    # ProxyPassReverse / http://localhost/
    
    SSLCertificateChainFile /etc/letsencrypt/live/www.example.com/chain.pem
    
    </VirtualHost>
    
    对于WordPress,将
    HOME
    SITEURL
    设置为:

    define('WP_HOME','https://example.com/blog');
    define('WP_SITEURL','https://example.com/blog');
    

    您应该设置您的应用程序,以便它使用HTTPs。我仍然会把Radiant或Refinery放在WP的垃圾堆上。我想,因为我不得不撤销代理,还想让/blog指向WordPress的安装,这并不是那么简单。WordPress提供了定制主题和插件,而这些主题和插件在这些鲜为人知的引擎中并不容易获得。