Welcome! Log In Create A New Profile

Advanced

Re: apache rewrite to nginx

Aleksandar Lazic
June 14, 2017 04:28PM
Hi frank3427.

frank3427 wrote on 14.06.2017:

> so far I have come up with the following but , I have been reading that
> using if statements is bad.
>
> if ($http_host ~ "^rwa-(.*)"){
> set $rule_0 1;
> set $bref_2 $2;
> set $bref_7 $7;
> }
> if ($http_host ~ "^m2m-(.*)"){
> set $rule_0 1;
> set $bref_2 $2;
> set $bref_7 $7;
> }
> if ($http_host ~ "^dwa-(.*)"){
> set $rule_0 1;
> set $bref_2 $2;
> set $bref_7 $7;
> }
> if ($rule_0 = "1"){
> rewrite ^/(/ws/v[1-9]/dias/[^+]*)\+([^+]*)$
> https://${host_finder:$http_host}/$1\$bref_2B$2https://$$bref_7bhost_finder:$bref_25$bref_7bHTTP_HOST$bref_7d$bref_7d/$1/$bref_2B$2
> last;
> }
> if ($http_host ~ "^rwa-(.*)"){
> set $rule_1 1;
> set $bref_2 $2;
> }
> if ($http_host ~ "^m2m-(.*)"){
> set $rule_1 1;
> set $bref_2 $2;
> }
> if ($http_host ~ "^dwa-(.*)"){
> set $rule_1 1;
> set $bref_2 $2;
> }
> if ($rule_1 = "1"){
> rewrite ^/(/ws/v[1-9]/dias/.*)\+(.*)$ /$1\$bref_2B$2;
> }
> if ($http_host ~ "^rwa-(.*)"){
> set $rule_2 1;

Missing '}'

The config does not run in nginx and makes no sense?

I have installed nginx on a plain linux added the conf to
/etc/nginx/conf.d/default.conf and run nginx -t

###
nginx -t
nginx: [emerg] the closing bracket in "host_finder" variable is missing in /etc/nginx/conf.d/default.conf:31
nginx: configuration file /etc/nginx/nginx.conf test failed
###

Please read again

http://nginx.org/en/docs/http/server_names.html
http://nginx.org/en/docs/njs_about.html
http://nginx.org/en/docs/http/ngx_http_js_module.html
https://www.nginx.com/blog/tag/nginscript/

Untested suggestion without the host_finder call.

##
server {
server_name ~^(?<prefix>rwa|m2m|dwa)-(?<postfix>.*)$;

location / {
rewrite ^(/ws/v[1-9]/dias/[^+]*)\+([^+]*)$ https://$prefix/$1\%2B$2 redirect;
}
}
##

--
Best Regards
Aleks

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

apache rewrite to nginx

Frank Dias June 12, 2017 04:16PM

Re: apache rewrite to nginx

Aleksandar Lazic June 12, 2017 06:22PM

Re: apache rewrite to nginx

frank3427 June 14, 2017 01:36PM

Re: apache rewrite to nginx

frank3427 June 14, 2017 02:04PM

Re: apache rewrite to nginx

Aleksandar Lazic June 14, 2017 04:28PM

Re: apache rewrite to nginx

frank3427 June 14, 2017 04:45PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 302
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready