Welcome! Log In Create A New Profile

Advanced

Rewrite issue moving SAP from Apache to nginx

Posted by dgraham 
Rewrite issue moving SAP from Apache to nginx
August 30, 2013 04:37PM
Hey all - I am having trouble migrating from my Apache install the is perfroming the reverse proxy function for our SAP system to the newly installed nginx 1.5.4 (running on Windows 2012). I have been playing around for a couple days and have come close to getting this to work, but I am just missing something (or lots of somethings). I also believe one of my changes to make it work may be making it worse, but we will see. If someone can look at the old code and the new code and give me some pointers, I would appreciate it.

Old code:
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteCond %{REQUEST_METHOD} ^TRACE
# RewriteRule .* - [F]
RewriteLog "C:\Apache2.2\logs\supply.mydomain.com_log"
RewriteLogLevel 1
ProxyRequests Off
ProxyPreserveHost On
# RewriteCond %{HTTP_HOST} ^.*?proxy1.*
RewriteCond %(HTTP_HOST) !^supply\.mydomain\.com$ [NC]
RewriteRule ^/(sap.*) http://prd-srm.mydomain.com:8000/$1 [P,L]
RewriteCond %(HTTP_HOST) !^supply\.mydomain\.com$ [NC]
RewriteRule ^/irj/(.*) http://prd-ep.mydomain.com:50000/irj/$1?%{QUERY_STRING} [P,L]
RewriteCond %(HTTP_HOST) !^supply\.mydomain\.com$ [NC]
RewriteRule ^/logon/(.*) http://prd-ep.mydomain.com:50000/logon/$1?%{QUERY_STRING} [P,L]
RewriteCond %(HTTP_HOST) !^supply\.mydomain\.com$ [NC]
RewriteRule ^/webdynpro/(.*) http://prd-ep.mydomain.com:5000/webdynpro/$1?%{QUERY_STRING} [P,L]
RewriteCond %(HTTP_HOST) !^supply\.mydomain\.com$ [NC]
RedirectMatch 301 ^/$ https://supply.mydomain.com:443/irj/portal
RewriteCond %(HTTP_HOST) !^supply\.mydomain\.com$ [NC]
RedirectMatch 302 ^/irj$ https://supply.mydomain.com:443/irj/portal

</IfModule>

<IfModule mod_alias.c>
</IfModule>
<IfModule mod_proxy.c>
# <Proxy http://supply.mydomain.com/irj/*>
# Order Deny,Allow
# Allow from all
# </Proxy>
<Proxy http://supply.mydomain.com/irj/*>
ProxyPass http://prd-ep.mydomain.com:50000/irj
ProxyPassReverse http://prd-ep.mydomain.com:50000/irj
</Proxy>
<Proxy http://supply.mydomain.com/logon/*>
ProxyPass http://prd-ep.mydomain.com:50000/logon
ProxyPassReverse http://prd-ep.mydomain.com:50000/logon
</Proxy>
<Proxy http://supply.mydomain.com/webdynpro/*>
ProxyPass http://prd-ep.mydomain.com:50000/webdynpro
ProxyPassReverse http://prd-ep.mydomain.com:50000/webdynpro
</Proxy>

</IfModule>
LogLevel warn

New code (nginx):
server {
listen 80;
server_name supply.mydomain.com;
location /{
return 301 http://supply.mydomain.com/irj/portal;
}
location /irj {
proxy_pass http://prd-ep.mydomain.com:50000/irj;
}
location /sap {
proxy_pass http://prd-srm.mydomain.com:8000;
}
location /webdynpro {
proxy_pass http://prd-ep.mydomain.com:5000/webdynpro;
}
}


Thanks much!

Cheers

David Graham
Re: Rewrite issue moving SAP from Apache to nginx
September 25, 2013 05:14PM
After many different attempts I have gotten back to this which should handle the proxypassreverse. I would still think this should help with the rewrites, but it must not. Also note that the site works internally but not externally. Still works on Apache and not sure how to get this to convert over correctly.

access_log logs/supply.mydomain.com.log;
listen 80;
proxy_buffering off;
server_name supply.mydomain.com;
location ~ ^/$ {
return 301 http://supply.mydomain.com/irj/portal;
}
location /irj/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://prd-ep.mydomain.com:50000/irj/;

}
location /(sap.*) {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://prd-srm.mydomain.com:8000/;
}
location /webdynpro/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://prd-ep.mydomain.com:50000/webdynpro/;

}
location /logon/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://prd-ep.mydomain.com:50000/logon/;

}
}
Re: Rewrite issue moving SAP from Apache to nginx
September 27, 2013 03:32PM
For grins I ran the Apache config through one og the Apache to NGINX converters and received the following code that works but I am still getting stuck at the same point, which is the outside frames are drawing correctly but trying to get the inside frame fails.

location ~ ^/$ {
rewrite ^(.*)$ https://supply.madden.com:443/irj/portal redirect;
}

location ~ ^/irj$ {
rewrite ^(.*)$ https://supply.madden.com:443/irj/portal redirect;
}

location ~ ^/$ {
rewrite ^(.*)$ https://supply.madden.com:443/irj/portal redirect;
}

location ~ ^/irj$ {
rewrite ^(.*)$ https://supply.madden.com:443/irj/portal redirect;
}

location / {
rewrite ^/(sap.*) http://prd-srm.madden.com:8000/$1 redirect;
rewrite ^/(sap.*) https://prd-srm.madden.com:8445/$1 redirect;
}

location /irj {
rewrite ^/irj/(.*) http://prd-ep.madden.com:50000/irj/$1?$query_string redirect;
rewrite ^/irj/(.*) https://prd-ep.madden.com:50001/irj/$1?$query_string redirect;
}

location /logon {
rewrite ^/logon/(.*) http://prd-ep.madden.com:50000/logon/$1?$query_string redirect;
rewrite ^/logon/(.*) https://prd-ep.madden.com:50001/logon/$1?$query_string redirect;
}

location /webdynpro {
rewrite ^/webdynpro/(.*) http://prd-ep.madden.com:5000/webdynpro/$1?$query_string redirect;
rewrite ^/webdynpro/(.*) https://prd-ep.madden.com:50001/webdynpro/$1?$query_string redirect;
}
}

I am seeing this error in the log. Same error as I have been seeing.
2013/09/27 14:22:54 [error] 3204#184: *768 CreateFile() "C:\nginx/html/sap(ZT1HbkhlV0M3UHMwUzlvaG5EdUFtMjJBLS11VlhKNDJyVmFGQkNZQ1hKNEphNHNnLS0=)/bc/gui/sap/its/BBP_QUOT" failed (3: The system cannot find the path specified), client: 70.194.77.27, server: supply.madden.com, request: "GET /sap(ZT1HbkhlV0M3UHMwUzlvaG5EdUFtMjJBLS11VlhKNDJyVmFGQkNZQ1hKNEphNHNnLS0=)/bc/gui/sap/its/BBP_QUOT?sap-client=100&sap-language=EN&sap-accessibility=&%7EDisconnectOnClose=0&%7EDesignBaseUrl=http%3A%2F%2Fprd-ep.madden.com%3A50000%2Firj%2Fportalapps%2Fcom.sap.portal.design.portaldesigndata%2Fthemes%2Fits&%7Edesign=Madden HTTP/1.1", host: "supply.madden.com", referrer: "http://supply.madden.com/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!2fmadden!2fprojects!2fProcurement!2fRoles!2fcom.madden.procurement.SRM_Supplier!2fcom.madden.procurement.Supplier!2fcom.madden.procurement.ProcessBid_Supplier?windowId=WID1380309761467"



Anyone, Anyone, Bueller?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 172
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