Tag Info

New answers tagged

0

If it's only about 'topic' argument this might work: On 'http' level of your nginx.conf declare following 'map': map $arg_topic $topic_id { "~^\d+\.msg(?<id>\d+)" $id; default 0; } On 'server' level add appropriate 'location': location = /forum/index.php { #if ($topic_id = 0) { # return 403; #} ...


1

Putting this in the server config block should work: the regexp should match what you need correctly and by stashing the required ID in a variable you can use it later in the rewrite. Assuming that you won't have a 'topic' argument in other parts of the site, there's really no need to scope this in a location - even if you do, you can alter the first part ...


1

i think your first vritualhost config is acting as the default for any request on hosts not matching 'test1.com' and 'test2.test.eu'. Try adding this ServerAlias line to see if it gets the request going to the proper config file. Rewrites in domain test2.test.eu config file: ServerName test2.test.eu ServerAlias www.test2.test.eu *.test2.test.eu ...


0

On a global proxy level I've done it using session cookies like this: <Proxy *> Order deny,allow Deny from all SetEnvIf Cookie "authtoken=myCookie" let_me_in Allow from env=let_me_in </Proxy> You may be able to restrict access to individual directories based on cookies using explicit URLS in the Proxy config like this: <Proxy ...


0

The answer is that it was actually working and that is was just the cache not refreshing when I ran a service nginx reload. The solution was to use service nginx force-reload (or restart though that is overkill) and it would work


0

This is the fix to my question, after doing alot of research on issues, I've found out that it was pretty straight forward: server { listen 127.0.0.1:80; server_name virjox www.virjox; root home/virjox/public_html; index index.php; log_not_found off; #access_log logs/virjox-access.log; charset utf-8; sendfile on; location ~ /\. { deny all; } location ...


1

Requests processing The base rule to remember is: nginx serves a request with one location (you could emphase even more: and one location only). Read: http://nginx.org/en/docs/http/request_processing.html location matching Read: location documentation Based on your configuration, nginx will first match on the /blog prefix location, then on the \.php$ ...


1

Right now any and all requests are going to hit this server block: server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name _; # This doesn't do anything rewrite ^ $scheme://www.example.com$request_uri permanent; # Rest of file irrelevant } Because: no server block has a valid server_name ...


0

Hash the filenames. The set_md5 instruction doc # You can do this: # I didn't test this. location /hashed/([0-9a-f]{2})([0-9a-f]*)/(.*) { try_files /$1/$2/$3; } set_md5 $digest $request_uri; location / { rewrite .* /hashed/$digest/$request_uri; }


1

Rewrite configurations are not inherited by virtual hosts. In order to "inherit" the directives in the vHost configurations, each vHost configuration needs: RewriteEngine on RewriteOptions Inherit See the Apache discussion under the mod_rewrite module at: http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html In any case, if you have access to the ...


1

You need to at least learn the basics of regular expression writing and nginx request processing. This is more appropriate : location /donor/ { rewrite ^/donor/(\d{4})/(\d{2})/(\d{2})/(\w+)$ /donor.php?yyyy=$1&mm=$2&dd=$3&donor=$4? break; proxy_pass http://X.X.X.X; proxy_redirect off; proxy_set_header X-Real-IP ...


1

TLDR: No. You can't. It isn't MTA job. Suppose external address send email to gapps domain. Here the full email looks like From: alice@external.example.com To: user@GAPPS.example.net Subject: Hello World This is 'Hello world' version of email Because user@GAPPS.example.net forwarded it to postfix.example.org then user@postfix.example.org get and read ...


2

The nginx documentation for rewrite (http://nginx.org/en/docs/http/ngx_http_rewrite_module.html) states that unless you end the replacement string with a '?' all previous qstring vars are appended. This means you don't need to (and probably shouldn't be) adding your qstring vars to the replacement. Also I would be as specific as I could be on the location ...


0

Rewrite changing domain A drop in rewrite rule to rewrite example.com → www.example.com is: RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] As mentioned by BillThor, http can be replaced with %{REQUEST_SCHEME} to be scheme independent. What's wrong with the rules in the question? I hope someone ...


0

I would define the virtual host to have the desired domain as its server name. # Virtual host definition with desire canonical name ServerName www.example.com ServerAlias example.com Use CanonicalName on You could use a passthrough rule to avoid the redirect. This is invisible to the client (browser). There are multiple ways to redirect the ...


1

That doesn't really matter execpt if your nginx server will deal with thousands of requests per second and you want to avoid each request to spend CPU time in rewrite regexs matching. Now, I would say use the most clear way to write your configuration files until you reach this limit then if you don't have the budget to scale your infrastructure, it would be ...


1

You can use rewrite with 'permanent' keyword, for example: rewrite ^/our-office/laos/(.*)$ https://domain.com/laos/$1 permanent;


0

I don't know why it doesn't work for you, but the HAProxy documentation states: There may be as many "use_backend" rules as desired. All of these rules are evaluated in their declaration order, and the first one which matches will assign the backend. From: http://cbonte.github.io/haproxy-dconv/configuration-1.4.html#4-use_backend Looking at your ...


0

Now example.com/store/my-funny-test-product.html works but CSS images and the like are broken! Use try files Requests for css files (or, any actual files in /var/www/example.com/public_html/store) aren't working at the moment because the requeset is routed unconditionally to /store/index.php. The minimal change necessary to make that work - is to use ...



Top 50 recent answers are included