Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing nginx as reverse proxy for apache and want more htaccess control
    primarykey
    data
    text
    <p>I'm using nginx in a reverse proxy configuration with apache2. I have used other, preconfigured web servers in this way and enjoyed complete control over redirects from an .htaccess file.</p> <p>My current configuration does not allow for this. First, I'll explain what happens.</p> <p>Let's say I want to redirect /google to <a href="http://google.com" rel="nofollow">http://google.com</a>. I add the following line to my .htaccess file.</p> <pre><code>redirect 307 /google http://google.com </code></pre> <p>I know it's working because I can test with curl from my server. This is hitting apache directly, behind the proxy.</p> <pre><code>curl -I localhost:8080/google </code></pre> <p>and I get a 307 as I would expect.</p> <p>But if this request hits nginx from the outside, nginx knows there is no such file in the web root and responds 404.</p> <p>Is there a configuration change I can make to remedy this?</p> <p>Here's my nginx configuration file for this vhost.</p> <pre><code>server { listen 80; root /var/www/mywebsite.com/html; index index.php index.html index.htm; server_name mywebsite.com; access_log /var/log/nginx/mywebsite.com.access.log; error_log /var/log/nginx/mywebsite.com.error.log; location / { try_files $uri $uri/ /index.php; } location ~ \.php$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } location ~ /\. { deny all; } } </code></pre> <p>It seems that I might need to take the reverse approach and proxy everything but exclude certain file types from the proxy.</p> <p>Thanks for advice folks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload