title: Flask redirect method redirecting to localhost
body: <p>I am using apache2 and gunicorn to deploy my flask app, but whenever I use <code>redirect</code> method. it's redirecting to <code>127.0.0.1</code>.</p>
  <pre class="lang-py prettyprint-override"><code>@module.route(&quot;/login&quot;, methods=[&quot;GET&quot;, &quot;POST&quot;])
  def u():
      if request.method == &quot;GET&quot;:
          return render_template(&quot;admin/login.html&quot;)
      
      username = request.form.get(&quot;username&quot;)
      password = request.form.get(&quot;password&quot;)
  
      for user in users:
          if username == user[&quot;username&quot;] and password == user[&quot;password&quot;]:
              session[&quot;user&quot;] = user
              return redirect(url_for(&quot;admin.stories&quot;, num=1))
      
      return redirect(url_for(&quot;admin.u&quot;))
  </code></pre>
  <p>as you can see when wrong username or password entered I am redirecting to itself, when the redirect happen, its going to <code>https://127.0.0.1/admin/login</code></p>
  <p><strong>/etc/systemd/system/app.service</strong></p>
  <pre><code>[Unit]
  Description=Gunicorn instance to serve flask application
  After=network.target
  
  [Service]
  User=anyms
  Group=www-data
  WorkingDirectory=/home/anyms/src/
  Environment=&quot;PATH=/home/anyms/venv/bin&quot;
  ExecStart=/home/anyms/venv/bin/gunicorn --config gunicorn_config.py wsgi:app
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  <p><strong>/etc/apache2/sites-available/app.conf</strong></p>
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin anyms@ubuntu
  
      ErrorLog ${APACHE_LOG_DIR}/flask-error.log
          CustomLog ${APACHE_LOG_DIR}/flask-access.log combined
  
      &lt;Location /&gt;
          ProxyPass unix:/home/anyms/src/app.sock|http://127.0.0.1/
          ProxyPassReverse unix:/home/anyms/src/app.sock|http://127.0.0.1/
      &lt;/Location&gt;
  &lt;/VirtualHost&gt;
  </code></pre>