onsuccess and always mod_header Apache2.4 and cache control - aem

Apache2.2 this rule worked fine for curl -I when content is not cached.
Header always set Cache-Control "public, max-age=86400"
Moving to 2.4 cache control header is missing on curl -I ,but works fine for GET request when content is pulled from AEM and stored inside cache, backend is Adobe AEM and apache has AEM dispatcher module.
To make it work i have add .
`Header always set Cache-Control "public, max-age=86400" "expr=%{REQUEST_STATUS}` == 200"
Header always set fixes the issue , why this behavior change how can i troubleshoot this issue , also i read somewhere like apache have some internal table of responses headers i am not able to find any on documentation . if this is not satisfied then Header set (on success) wont work.

Related

Redirects issue in ngrinder groovy-Eclipse plugin

I am facing an issue when I am scripting the redirects in nGrinder (Script written in Groovy in Eclipse; Eclipse integrated with Groovy plugin) for the URL: https://winterfell-sbo-sbo-test-cso-web-mta.cfapps.sap.hana.ondemand.com/sites
Attached is the Eclipse log (Page #11, #12, #13) for your reference and below is the explanation on the issue.
Step#1
I fire a HTTP GET request on https://winterfell-sbo-sbo-test-cso-web-mta.cfapps.sap.hana.ondemand.com/sites.
This automatically follows redirects and then lands on to the Login Page: https://winterfell.authentication.sap.hana.ondemand.com/login
Step#2
I fire another HTTP GET request on 'https://winterfell.authentication.sap.hana.ondemand.com/saml/discovery?returnIDParam=idp&entityID=winterfell.canary&idp=winterfell-metadata&isPassive=true
This doesn't automatically redirect to "Location" header -> https://winterfell.authentication.sap.hana.ondemand.com/saml/login/alias/winterfell.canary?disco=true&idp=xs2security.accounts400.ondemand.com
Refer to the screenshot for more information.
Instead it gets redirected to https://winterfell.authentication.sap.hana.ondemand.com/login
We tried to capture and set the csrf cookie for the GET request of https://authentication.sap.hana.ondemand.com/saml/discovery?returnIDParam=idp&entityID=winterfell.canary&idp=winterfell-metadata&isPassive=true -> but still it isn't working as expected
Colleague was able to make this work in JMeter. So we are trying to simulate this in nGrinder by setting "followRedirects" to true and it isn't working as expected.
Since in Step#2, it is not picking up the location of the response header and redirecting back to "/login" page, what could be the possible reasons for this behavior?
we checked if xsuaa is working fine. On executing the request in Postman, everything worked as expected. Curl works well.

How to disable teamcity server url autodetection or fix server url manually?

I have my Teamcity instance been setup by defaults. Its behind nginx, so i had moved /WWW folder to /teamcity folder and had set nginx location record up like that.
location /teamcity {
proxy_pass http://localhost:8111/teamcity;
# and a couple of _sets here
}
everything works fine except Nuget feed. I can list packets from it but i cant download any packet because the packet URL.
It looks like:
1. http://some.domain.com:443/teamcity/whatever/url/for/the/packet/(correct one)
instead of:
2. https://some.domain.com/teamcity/(correct URL)
The packets at the second URL are accessible but feed returns me firs one. URLs in "General Settings" and "main-config.xml" are correct also. Is that because of URL auto detection, so can i disable it some how or is it because of another issue?
Server URL autodetect is not related to this problem. If you have custom URL specified, then autodetect will be disabled.
Make sure you pass all necessary headers as specified in our documentation: https://confluence.jetbrains.com/pages/viewpage.action?pageId=74845225#HowTo...-NGINX

Gitlab change redirect for nonexistent paths away from login page

Using omnibus gitlab 9.2.
Action: As a non-logged-in user, attempt a request for a public project that doesn't exist (at least not publicly).
Result: Receive a 302 redirect to /users/sign_in from nginx.
What I'd like to see: Receive a 302 redirect to /public (or wherever, for that matter)
What I've tried without success: Adding this to gitlab.rb:
nginx['custom_gitlab_server_config'] = "try_files $uri $uri/ /public;\n\nfastcgi_intercept_errors on;\n\n"
I couldn't find the explicit redirect in any nginx conf, so I guess it's in Rails. I'll peruse that code.
This is actually a custom HA configuration with the gitlab nodes behind haproxy fronts. I thought about possibly doing something on the fronts, but couldn't come up with anything.
Thanks!
Edit:
I see now that replacing the unmatched_route line in routes.rb with:
get '*unmatched_route', to: redirect('/public'), via: :all
does what I need, but I'd of course want to make that change persistent. Is that possible?

Suppressing server information in response header for WAS 6.1 not working for https redirection

My application is directed from http to https. I have security issue to remove the server info in response header. I could see no server info in http response.. but once it is redirected to https, in the response header still the server info exists. how to remove the server info in both the cases... using WAS 6.1,webserver IHS 6.1. any chages to be done in httpd.conf file...thanks in advance...
IHS is an apache based server. To make it less talky about itself you need to add (or modify) a few directives. In short you need to find a line saying ServerTokens and make sure it reads ServerTokens Prod (add the line if it does not exist). ServerTokens reference
Also double check for a line with thte directive ServerSignature. If it does exist it should read ServerSignature Off (which is default) ServerSignature reference
If this is not enough, you can modify the response headers directly. To do that you would need to add a directive like Header unset Server which would remove all response headers with the name Server. Make sure this is what you want though! Header reference
Finally, remember to restart your IHS after you're done with the changes.

XDebug and RESTful server using PHPStorm or POSTman

How can I get a REST client (such as the one built into PHPStorm or POSTman) to work with XDebug?
In my current set-up of XDebug, using PHPStorm and the Bookmarklet provided I'm able to get it working in both Chrome and Firefox - but as soon as I try with POSTman or any other REST client, I can't figure out how to get it started.
Cheers.
You can use one of these approaches:
Configure your Xdebug (by editing php.ini) to attempt to debug every PHP script. The key option:
Xdebug v2: xdebug.remote_autostart = 1
Xdebug v3: xdebug.start_with_request = yes
Add Xdebug session start parameter to the actual URL (XDEBUG_SESSION_START={{KEY}} -- https://xdebug.org/docs/step_debug#manual-init), for example: ?XDEBUG_SESSION_START=PHPSTORM
Pass Xdebug cookie as part of the request (the one which is set by bookmarklet or browser extension, for example).
For this to work: make sure that "phone handle" icon is activated in advance in PhpStorm (Run | Start Listen for PHP Debug Connection).
P.S. If you are using Postman, Insominia or alike (another REST client) then the best / most transparent way IMO is to use Xdebug cookie. You're most likely already using separate Environments (e.g. "dev", "test", "production") so you can have such a cookie only where it is needed (depends on the tool and version used of course).
This way there is no need to edit the URL (even if you have it as a "conditional parameter" that is present for some environment and absent for another) or configure Xdebug to "debug all requests" at all.
An example of such Xdebug cookie from my Postman (edit it as needed; here it is set for the local some-domain.local.test fake domain):
XDEBUG_SESSION=value; Path=/; Domain=.some-domain.local.test; Expires=Tue, 19 Jan 2038 03:14:07 GMT;
Since the host URL should be a part of your Environment (e.g. the endpoint URL will be like {{host}}/api/v1/welcome) then such cookie will be sent to the dev domain only and not to the production one.
Just add ?XDEBUG_SESSION_START=filter_string at the end of the url, for eg:
https://new-supplier.local/api/login?XDEBUG_SESSION_START=PHPSTORM
PHPSTORM is my default filter string, you can use whatever you want. Your editor should be set up to filter connections by IDE key (filter string), and thats it. You should be able to debug the same way as from Chrome or FF.
Warning!
xdebug >= 3.0 has changed the parameters in php.ini.
After upgrading xdebug, most of the answers here will not be relevant.
Refer to:
https://xdebug.org/docs/upgrade_guide
Basically, you need to add something like this to your php.ini:
xdebug.mode=develop,gcstats,coverage,profile,debug
xdebug.start_with_request=1
xdebug.idekey=PHPSTORM
This was driving me crazy. I just updated to PHP 7.1 and xdebug that was working no longer worked. I updated the xdebug.so file (Linux) and php --version indicated that xdebug was indeed being loaded and working. But when I would use Postman the debugger never kicked on.
Here's the solution. If you are using Apache as your server then you need to enable the PHP 7.1 mods and reboot Apache: sudo service apache2 restart
xdebug.remote_timeout = 60000
Worked for me. As my Mac was very slow, and Remote debugger was timed out after 200 ms (Default value)
What finally got my Postman/PHPStorm Xdebug working was adding a PHP Remote Debug configuration in PHPStorm:
Run -> Edit Configurations -> + -> PHP Remote Debug
I just set the name to localhost and saved it - no IDE Key, etc.
you can set xdebug cookie into postman to use it from postman as well.
their are one link Cookies under the Send button click on it. and add new cookie. XDEBUG_SESSION = PHPSTORM their and save
Configure PHPStorm XDebug to trigger on RESTful API requests
Please, check this answer => https://stackoverflow.com/a/73802240/13321079