django - 域名 url 重定向到 apache2 中的 localhost

标签 django ubuntu amazon-ec2 apache2 hosting

我在将我的域名映射到在 8000 端口上运行的托管 django 应用程序时遇到问题。我看过很多关于这个问题的帖子,但我认为我错过了一些东西。我尝试了很多方法,但都失败了。我的域名是coachingfunda.com,它与我在Godaddy 中的ec2 公共(public)IP 地址映射。我的 000-default.conf 文件是

    LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
    LoadModule proxy_http_module        /usr/lib/apache2/modules/mod_proxy_http.so
  LoadModule headers_module /usr/lib/apache2/modules/mod_headers.so
LoadModule deflate_module  /usr/lib/apache2/modules/mod_deflate.so

  <VirtualHost *:80>
  WSGIScriptAlias /wsgi/ /home/ubuntu/public_wsgi/
 #ProxyPreserveHost On
  #ProxyPass / http://nrollin.com:8080/nrollin
    # The ServerName directive sets the request scheme, hostname and         port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
     #ProxyPassMatch ^(.*)$ http://localhost:8000/$1
   #ProxyPass / http://coachingfunda.com/
  # ProxyPassReverse / http://127.0.0.1:8000/
ServerAlias www.coachingfunda.com
 ServerName coachingfunda.com
  #AliasMatch ^/(.*)  http://www.coachingfunda.com:8000/$1
Redirect permanent http://coachingfunda.com http://www.coachingfunda.com:8000/
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf

你可以看到这个 url 正在工作 http://coachingfunda.com:8000/这意味着我的应用程序已正确托管,但 http://coachingfunda.com正在重定向到 localhost:8000。

这个问题似乎很愚蠢,但我被困了大约 2 天。请在这里帮助我。我的 coachingfunda.conf 是
   <VirtualHost *:8000>
    ServerAdmin webmaster@mydomain.com
    ServerName coachingfunda.com
    ServerAlias www.coachingfunda.com
    WSGIScriptAlias /  /var/www/coachingfunda/index.wsgi

    Alias /static/ /home/ubuntu/coachingfunda/static/
    <Location "/static/">
  Options -Indexes
    </Location>
   <Directory "/home/ubuntu/coachingfunda/static/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
   </Directory>
    </VirtualHost>

请帮我。任何建议都可能奏效。

最佳答案

备份您的默认配置并将站点中的配置复制到默认配置中,然后重新加载并重新启动服务器。

关于django - 域名 url 重定向到 apache2 中的 localhost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31199706/

相关文章:

Django CSRF 验证失败。请求中止。- CSRF cookie 未设置

python - Django - 如何在登录时设置默认值 request.session ?

c - 如何使用 css 降低 gtk 对话框的标题栏高度?

python - 以用户 postgres 身份运行命令行导致找不到模块

amazon-web-services - CircleCI 部署到 AWS EC2

python - Django : Mezzanine front search module

javascript - 将数据参数(而不是查询参数)提供给 window.location.href ?创建动态文件

linux - crontab 无法运行以指定时间间隔获取 url 的 shell 脚本

amazon-web-services - 如何使用 eb cli 指定 EC2 安全组

amazon-web-services - AWS :EC2 enable dns-hostname for host in non default vpc