Can IIS log the sub domain part of the url? - iis

I have a website served by IIS. Logging is turned on and i get infrmation like:
2013-02-26 00:23:16 ::1 GET /Test/TestPage.html <snip>
But I have a subdomain per customer so that a.mydomain.com and b.mydomain.com both point (via CNAME) at the same installation and serves the same files (but I have code that shows different data).
What I'd like is to be able to say that customer a hit the website x times and downloaded y but and customer b hit it z times (etc).
But the a.mydomain.com doesn't seem to be logged and doesn't look like I can turn it on.
Is it possible to get this information?

Yes, you can enable that by opening IIS Manager, clicking in Logging, then "Select Fields" button and choose Host (cs-host).
If you want the command line version would look something like:
%windir%\system32\inetsrv\appcmd.exe set config -section:system.applicationHost/sites /siteDefaults.logFile.logExtFileFlags:"Date, Time, ClientIP, UserName, SiteName, ServerIP, Method, UriStem, UriQuery, HttpStatus, Win32Status, TimeTaken, ServerPort, UserAgent, Referer, Host, HttpSubStatus"
Note that this will change it for all sites (since its modifying the siteDefaults section), but you could make it apply only to a specific site if desired.

Related

Reverse proxy passthrough for multiple websites

I'm building a website where there will be user generated content, for example under the url website.com. Each user might have a page (of their own content) somewhere like website.com/user/jack, website.com/user/lucy, etc. This number of users (as well as their names) are dynamic and can be added any time. I already have website.com working and deployed.
I'd like to be able for users who have their own domain name, e.g. jacks-website.com, to be able to use that domain name but effectively have it act and behave as website.com/user/jack. By this, I mean the following:
jacks-website.com is has the same DNS records as website.com.
jacks-website.com serves exactly the same content as website.com/user/jack. This also goes for any/all (nested) subpaths, i.e. jacks-website.com/custom-path -> website.com/user/jack/custom-path.
A user browsing jacks-website.com will have NOT be directed to website.com/user/jack. To them it should feel like browsing jacks-website.com directly.
I've tried playing around with Node's http-proxy package, where I would check what req.headers.host is then map it to a corresponding /user/jack path. However, I still couldn't get it to work as it would cause jacks-website.com to redirect to jacks-website.com/user/jack.
Also note that I'm fully using SSG/SSR on my website.com app, so no need to worry about client-site routing or anything.
Thanks a lot.

How to sort the files by "Data Modified" in IIS Server 7.5?

I have enabled 'Directory Browsing' for only "logs" folder of my Web Application hosted via IIS 7.5
Whenever I type www.domain.name//logs in my Browser, I could see the log files listed.
I would like to see the files sorted by 'Date Modified',i.e, the latest log must come at top and the oldest log must be present at the bottom.
How to go about this?
Is this possible in IIS 7.5 in first place?
As far as I know there is no out of box setting/configuration available with which you can sort directory/file list displayed in browser. Of course that doesn't stop you writing your own custom HTTP module. Here is broad idea.
Intercept directory requests to your application.
In Http module handle OnPreRequestHandlerExecute event.
In even handler get directory/file list.
Create nicely formatted page which will display list from step 3. Here you can format/sort way you like it.

OpenCart 2.0.0. - SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK

In OpenCart v. 2.0.0 in /admin when I receive an order I should be able to change status of the order to let the customer know what is going on with her purchase. This functionality is in 'History' tab.
Unfortunately I can't change or modify any orders.
When I change the status and try to save it Openart gives me an error:
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data OK
It happens even on clean install. Everything is set up correctly - the domain name is OK, the shop is not in maintenance mode, there is no password in .htaccess file (BTW even removing it doesn't help).
It looks like in the screenshot attached.
The one solution is to install the newest version of OpenCart which is in the moment I'm writing this post 2.0.1.1. It's probably the best idea.
My problem is that I have made quite a lot of modifications and that would be very difficult for me. Making my changes I didn't use vqmod which probably I should use (but nobody is perfect - isn't she?).
Or maybe you don't want to go into upgrade for a different reason?
Now, how to resolve this problem without actually changing the software itself?
I got the same error and I fixed it:
Go to Admin -> System -> Users -> API
Add a new API generate password, and enable it
Then go to Admin -> System -> Settings -> Edit -> Option(tab)
Select API user under Checkout section as your API user
Then save the changes
Then go to Sales -> Orders -> Edit
I guess that the error comes when a cURL method in your OC tries to get data from the OC API and gets blocked.
-- Quick Testing
Goto function info() in /admin/controller/sale/order.php
find the curl initialization inside info() and aim on $json = curl_exec($curl);
add after that:
if($json === false){
var_dump(curl_error($curl));
exit;
}
if there is an error, you should see it when you go to an order info from your admin panel.
You may have a refused connection msg on 80 or 443 port.
If yes, possible errors and solutions may be:
You are working in a protected directory.
This is a website message (like js alert with fields) that asks for user/pass.
You may turn it off and try again to add a history record.
In Plesk you can find it as "Password Protected Directory" in domain options.
If you recently modify your .htaccess, you should check it for auth statements causing the above symptoms.
PHP; Check if you have added any $_SERVER['REMOTE_ADDR'] into an if block to reject ips on purpose.
When using Plesk, have root access (ssh), and you have the same website domain as the Plesk admin panel hostname,
(assume that your domain is www.yourdomain.com)
you can check from your ssh, executing curl -vv "http://www.yourdomain.com" (or https) inside of your own server (localhost) which your domain is hosted.
If you get a refused connection on port 80, or 443 for https and have a success return msg on curl -vv "http://www.yourdomain.com:7080" OR curl -vv "http://www.yourdomain.com:7081" (virtualhost ports) then you can fix it as below. It is also strange to get a successfull connection msg on 80 & 443 when try it from other server!
So, you have to modify your server hosts (/etc/hosts) and add right to your public ip your full website domain (last line usually).
So, add to the public-ip line xxx.xxx.xxx.xxx www.yourdomain.com. You may have other hosts defined right on your public ip. Please, do not remove any. Add www.yourdomain.com in the last of the piblic-ip line. You can check again with curl, or adding an order history.
I may help,
giannisepp
After some hard time I managed to solve this problem and I want to share this solution with you:
In the admin panel of your shop go to:
Admin > Settings > Users > API
There should be one user with name like
XrpeYEWrFHOcqB1phjBXdUCRO1A3sCvDpgmTGBcJ7G6WuYIMKXCrIJUpzvFPfimWT6LHQLisTYz0nuOy7ZK
if there is not create one and give her reasonably complicated name like in the example.
Then you have to check out your database (using phpMyAdmin helps a lot) where keeps your store data.
find the api table which contains the API user and check the api_id of this user.
find table setting (by default OpenCart instalation it's named oc_setting) and find key config_api_id.
Set the value field to the same number as the api_id you had found in the api table.
Problem should be solved.
In my OpenCart 2.0.0 installation the value was set to 0 while the api_id was 2.
I had the same issue and tried all workarounds possible and imaginable.
In the end gave up and called my hosting provider. They found that OpenCart wont run properly on any php version above 5.4.33. Ergo: use php 5.4.33
This might not solve all issues, or might work only in conjunction with other fixes bove, but itÄs worth a try to check which php version your hosting is running by default.
If your server does not support HTTPS, please modify the https to http.
Open the admin/config.php file, modify the https to http.
define('HTTPS_SERVER', 'http://'.$_SERVER['HTTP_HOST'].'/admin/');
define('HTTPS_CATALOG', 'http://'.$_SERVER['HTTP_HOST'].'/');
Disabling maintenance mode did it for me.
In admin/controller/sale/order.php file line below 2438 you should see like this:
if ($store_info) {
$url = $store_info['ssl'];
} else {
$url = HTTPS_CATALOG;
}
As you can see CURL is allways use HTTPS_CATALOG defined constant which contain your shop SSL URL. Why? I don't now.
The solution: edit your config.php on shop root folder and change HTTPS_CATALOG defined constant value to non-ssl URL, simply delete "s" after end of https.

IIS V6 autoblocking ip

the linux-guy here has a question about IIS v6.
The case is, that i have a site running, when i do some specific tasks on this site ( Like deleting a specific item, three times in a row) the site will break, and a completely blank page will appear. Checking the response headers, i noticed that the server sends a "403 Forbidden: IP address of the client has been rejected."
Through a proxy, i can connect just fine.
Checking the site-options in the IIS manager, shows me that my IP is not blocked globally, its something thats just happening.
Where can i check for this? It happens automatically and the block ends after about 8-12 minutes, every time?
best regards.
Jonas
do you have access to IIS?
i assume blocking occure on web site side (inside ASP code), not in IIS.
please check IIS console, and make sure that there are no blocked IP's. If it's true, you should find database/table or some config file, where stored all blocked IP's. After that, you should get able to find ASP code, which is responsable for blocking....
you also could try make quick search inside all ASP pages for text like: "REMOTE_ADDR" and ".ServerVariables"

Allow user when registered to browse to username.host.com

I am using Asp.net MVC3 and C# and IIS 7.5. I want that once user is registered he can browse my site using username.host.com and this username should be available to me in my URL so I can show the data related to that particular username only. All the logic is the same for all users. I don't want to do any fancy thing like if user1.host.com is entered then I want to redirect to a separate controller and action etc. All the application logic is the same for all users. I just want to change the way the url is shown in the browser.
Also, if possible I want this to work on localhost also in IIS/Cassini.
Eg: If I browse to jaggu.localhost:19883. It should send me to localhost:19883/Home/index/Jaggu (because by default Home is the controller and index is the method)
I am completely clueless on how to achieve this. Any help would be appreciated.
You may need a star A record, like *.host.com that points to your host.com site.
On your default page (or elsewhere via something like an IHttpModule) reroute the request to where you want the registered user to land.
Google: URL Rewriting for more information.

Resources