How to limit error display to certain users or IPs - xdebug

Currently when there is a notice or warning, it is displayed on our web pages.
We would like this to be available only to some IPs or other criteria for our developers
Is there a way to render the error log stack only to certain IP?
Thanks

There is no feature in Xdebug that can do this.
What I would suggest to do is to create two web server vhost configurations, or php-fpm pools, if you're using that. With one configured to have Xdebug on, and the other to have it not activated and loaded. You can then use configuration in your web server to redirect incoming requests to either one of these PHP configurations, depending on the source IP address.

Related

Getting "Not Found The requested URL was not found on this server" when accessing from a specific domain?

We have a simple WP site that has been running for years. We can access it on mobile or any other computers that are not connected to our company's domain. I believe there is an error within our firewall. Any suggestions on where I should look? We use a Dell Sonicwall.
First check the logs, and see if it's being blocked. Then I would check app control, or the CFS policies. Probably, the easiest way would be to just put one test machine IP address in a CFS, IPS, or APP Control (or all) bypass group. Test you can get out to the site. Once you can access the site, start to re-enable all the security services one by one until you find out what's blocking it.

Debugging GAE microservices locally but without using localhost

I would like to debug my Google App Engine (GAE) app locally but without using localhost. Since my application is made up of microservices, the urls in a production environment would be along the lines of:
https://my-service.myapp.appspot.com/
But code in one service can call another service and that means that the urls are hardcoded. I could of course use a mechanism in code to determine whether the app is running locally or on GAE and use urls that are different although I don't see how a local url would handle the since the only way to run an app locally is to use localhost. Hence:
http://localhost:8080/some-service
Notice that "some-service" maps to a servlet, whereas "my-service" is a name assigned to a service when the app is uploaded. These are really two different things.
The only possible solution I was able to find was to use a reverse proxy which would map one url to a different one. Still, it isn't clear whether the GAE development SDK even supports this.
Personally I chose to detect the local development vs GAE environment and build my inter-services URLs accordingly. I feel it was a well-worthy effort, I've been (re)using it a lot. No reverse proxy or any other additional ops necessary, it just works.
Granted, I'm using Python, so I'm not 100% sure a complete similar Java solution exists. But maybe it can point you in the right direction.
To build the per-service URLs I used modules.get_hostname() (the implementation is presented in Resolve Discovery path on App Engine Module). I believe the Java equivalent would be getInstanceHostname() from com.google.appengine.api.modules.
This method, when executed on the local server, automatically provides the particular port the server listens to for each service.
BTW, all my services for an app are executed by a single development server process, which listens on multiple ports (this is, I guess, how it can provide the modules.get_hostname() info). See Running multiple services using dev_appserver.py on different ports. This is part I'm unsure about: if/how the java local dev server can simultaneously run multiple services. Apparently this used to be supported some time ago (when services were still called modules):
Serving multiple GAE modules from one development server?
GAE modules on development server
This can be accomplished with the following steps:
Create an entry in the hosts file
Run the App Engine Dev server from a Terminal using certain options
Use IntelliJ with Remote debugging to attach the App Engine Dev server.
To edit the hosts file on a Mac, edit the file /etc/hosts and supply the domain that corresponds to your service:. Example:
127.0.0.1 my-service.myapp.com
After you save this, you need to restart your computer for the changes to take place.
Run the App Engine Dev server manually:
dev_appserver.sh --address=0.0.0.0 --jvm_flag=-Xdebug
--jvm_flag=-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
[path_to_exploded_war_directory]
In IntelliJ, create a debug configuration. Use the Remote template to create this configuration. Set the host to the url you set in the hosts file and set the port to 8000.
You can set a breakpoint and run the app in IntelliJ. IntelliJ will attach to the running instance of App Engine Dev server.
Because you are using a port during debugging and no port is actually used when the app is uploaded to the GAE during production, you need to add code that identifies when the app is running locally and when it's running on GAE. This can be done as follows:
private String mServiceUrl = "my-service.my-app.appspot.com";
...
if (SystemProperty.environment.value() != SystemProperty.Environment.Value.Production) {
mServiceUrl += ":8000";
}
See https://cloud.google.com/appengine/docs/standard/java/tools/using-local-server
An improved solution is to avoid including the port altogether and not having to use code to determine whether your app is running locally or on the production server. One way to do this is to use Charles (an application for monitoring and interacting with requests) and use a feature called Remote Mapping which lets you map one url to another. When enabled, you could map something like:
https://my-service.my-app.appspot.com/
to
https://localhost:8080
You would then enable the option to include the original host, so that this gets delivered to the local dev server. As far as your code is concerned it only sees:
https://my-service.my-app.appspot.com/
although the ip address will be 127.0.0.1:8080 when remote mapping is enabled. To use https on local host however does require that you enable ssl certificates for Charles.
For a complete overview on how to setup and debug microservices for a GAE Java app in IntelliJ, see:
https://github.com/JohannBlake/gae-microservices

How to map a domain to server?

My AngularJS application running on NGINX server user profiles. I want users to point their domains to their profiles.
Example http://example1.com would serve http://example.com/#/foo profile.
I have created a custom nameserver i.e. ns1.example.com but I am not sure how to configure NGINX to point to the correct user account.
This is the sort of thing that you'll want to handle at the application level, and not in Nginx. That is, rather than updating and reloading your Nginx config files you should have something server side (like a lightweight Node.js application, for example) that would inspect the Host header. If the Host header value isn't your domain, then look up that domain in your database and serve up a 301 redirect..
Also note that there are some compatibility problems with using a redirect to an anchor fragment (like #/foo). Make sure you test well with the browsers that your users use most commonly.

How to monitor external traffic to my local IIS server?

I'm developing for mobile devices and to debug I connect devices on WIFI to my IP address. It works well for developing on hardware and debugging on my machine. The only thing I can't make to work is how do I set up Fiddler so it sees traffic coming from external clients?
If I open my site from browser on same machine - fiddler get's it. But when I connect to my PC by IP address from another machine - fiddler doesn't see it.
I have proper settings (I think)
You need to configure Fiddler as a reverse proxy. See Using Fiddler as a Reverse Proxy.
I got this to work by simply changing the IIS Application Pool whose traffic I wanted to inspect to run under my identity, since Fiddler seems to only capture traffic of the logged in user by default. Just make sure your user has all of the necessary permissions required by IIS; I'm an admin so this wasn't an issue for me. And of course, don't forget to change the IIS Application Pool identity back when you are done.
The other option of course is to instead log in as the user that the IIS Application Pool is running as (if it's not a service account like Network Service) and then run Fiddler while logged in as that other user.

Multiple websites on 1 VPS MVC

Right now I'm using shared hosting for my websites and I'm not very satisfied with it. Someone recommended a VPS instead but I have no idea which one to pick.
I'm developing ASP.NET MVC 3 sites and I have about 4 sites I need to host. I guess I should use IIS to host the sites but I'm a little bit confused.
Is it possible to point 1 domain name to each website I'm making? And what do I do if I want to send mail?
Example.
www.site1.com has some emails eg. info#site1.com
www.site2.com has some emails eg. info#site2.com
I guess I need a mail server? To be able to read and view my emails. like WorldClient
You can any number of domains on one single server. When you create the site on IIS Manager, give the different domain names in the host name field and point the relevant domains to the directory.
For mail server I generally go for Apache James, but this is console based app so configuring this is a bit tedious. Smarter Mail is also another option on windows with full windows GUIs for configuring the mail servers.
The mail servers can be configured in your DNS settings. So your mail.domain.com will become your mail server.
Btw, both mail servers I mentioned give you options for POP access for reading from outlook express etc.,

Resources