Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to forward that request to <code>/google</code> to <strong>apache</strong>, then just change the <code>location ~ \.php$</code> pattern to include the request you desire:</p> <pre><code>location ~ (/google/?)|(\.php)$ { </code></pre> <p>On the other hand if you want <strong>nginx</strong> to handle the redirect you can add new rule:</p> <pre><code>location ~ /google { return 307 http://google.com; } </code></pre> <p>Just make sure to put it <strong>before</strong> the <code>location</code> block which contains <code>try_files</code>.</p> <p>EDIT: To forward all requests that don't hit a file use this:</p> <pre><code>location / { if (!-f $request_filename) #test if a static file does not exists { # forward the request if there is no file to serve: 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; } } </code></pre> <p>Additionally if you want for nginx to also serve entire directories then add another condition:</p> <pre><code>!-d $request_filename </code></pre> <p>Also note that if you want only specific files to be served then instead <code>location /</code> use the pattern to match those files. For example if you want to serve only <code>jpg</code>'s and <code>css</code>'s use</p> <pre><code>location ~ \.(jpg|css)$ </code></pre> <p>EDIT2: Here you have a simplified version of your script, which is also more robust - lets you serve only the types of files you want:</p> <pre><code>server { listen 80; server_name test.lcl; root /home/www/test; location / { try_files $uri $uri/ @apache; } location @apache { 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; } } </code></pre>
 

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